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
How Would One Disable Nagle's Algorithm in Linux
How to Find Directory of Some Command
Does Linux Schedule a Process or a Thread
How to Pass a Wildcard Parameter to a Bash File
Remove a Symlink to a Directory
Nuget on Linux: Error Getting Response Stream
Why Do We Need a Bootloader in an Embedded Device
Bash Script to Remove 'X' Amount of Characters the End of Multiple Filenames in a Directory
Command to Change the Default Home Directory of a User
Relinking an Anonymous (Unlinked But Open) File
The Concept of 'Hold Space' and 'Pattern Space' in Sed
How to Kill All Linux Processes That Are Older Than a Certain Age
Docker-Compose Up and User Inputs on Stdin
Converting Serial Port Data to Tcp/Ip in a Linux Environment