Meaning of Tilde in Linux Bash (Not Home Directory)

Difference between $HOME and '~' (tilde)?

The shell replaces ~ with the user's home directory (update: or perhaps by the home directory of some other user, if ~ is followed by something other than a /), but only if it's the first character of a word.

--with-libmemcached=~ has ~ not in the beginning, so the shell leaves it alone.

What is the difference between ~/ and ~ in Linux?

~ means the home directory of the logged on user whereas ~/ means the path to the beginning of a directory.

From here:

The tilde (~) is a Linux "shortcut" to denote a user's home directory.
Thus tilde slash (~/) is the beginning of a path to a file or
directory below the user's home directory.

On a side note If you see like ~Gowthaman/ then it will be the user Gowthaman home directory

Tilde in path doesn't expand to home directory

You can do (without quotes during variable assignment):

a=~/Foo
cd "$a"

But in this case the variable $a will not store ~/Foo but the expanded form /home/user/Foo. Or you could use eval:

a="~/Foo"
eval cd "$a"

What does ~ mean in a Linux shell?

The ~ (tilde) is a quick way of specifying your home directory.

The ~/.somefilename means your home directory, the file .somefilename.

Tilde prefix returns invalid home directory

getent and finger commands were outputting a default home directory for a non-existent user (not retrieved using ldaplist) because the requests were handled through an intermediate access control mechanism such as Cisco SA Control for role based access control.

Why use $HOME over ~ (tilde) in a shell script?

Tilde expansion doesn't work in some situations, like in the middle of strings like /foo/bar:~/baz



Related Topics



Leave a reply



Submit