O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tilde Substitution

Tilde substitution is used to substitute the pathname of a user's home directory for user. Words in the command line that start with the tilde character cause the Korn shell to check the rest of the word up to a slash. If the tilde character is found alone or is only followed by a slash, it is replaced with the value of the HOME variable. This is a handy shortcut borrowed from the C shell. For example, to print the pathname of your home directory:

					$ echo ∼
					/home/anatole
				

or to list its contents:

					$ ls ∼/
					NEWS         bin         pc
					asp          mail        src
				

If the tilde character is followed by a login name file, it is replaced with the home directory of that user. Here we change directory to the tools directory in smith's home directory:

					$ cd ∼smith/tools ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required