0

I saw ~ here before the path of repository.

chmod a+x ~/bin/repo

What does ~ do here?

muru
  • 197,895
  • 55
  • 485
  • 740
rsp
  • 185

1 Answers1

2

It is short hand for $HOME or /home/your_current_user

I advise you avoid using it in scripts or with sudo as results can be unexpected.

You can also specify a user with ~user rather than /home/user

Basically save typing, usually works, but can yield unexpected results in scripts.

For the gory details see http://tldp.org/LDP/abs/html/special-chars.html

Those pages cover most anything you want to know about bash and cure insomnia ;p

home directory [tilde]. This corresponds to the $HOME internal variable. ~bozo is bozo's home directory, and ls ~bozo lists the contents of it. ~/ is the current user's home directory, and ls ~/ lists the contents of it.

Note "tab completion" also saves typing. start typing part of a path or command and press Tab

cd /hoTabTab

Helpful for commands and long paths other than ~

Again see http://www.tldp.org/LDP/abs/html/tabexpansion.html

Panther
  • 102,067