- Published on
TIL: `~foo` expands to the HOME dir of that user in Bash
We know that ~
is $HOME
, but it is more general that this. Usually, ~foo
will expand to /home/foo
, but could be anything as configured in /etc/passwd
Very handy when dealing with multiple users.
There's even more expansions like ~+/foo
and ~-N
. See Bash manual for further info.
PS: This trick even works in Firefox!