100 Useful Command-Line Utilities

by Oliver; 2014

2. pwd

To see where we are, we can print working directory, which returns the path of the directory in which we currently reside:
$ pwd
Sometimes in a script we change directories, but we want to save the directory in which we started. We can save the current working directory in a variable with command substitution:
d=$( pwd )		# save cwd
cd /somewhere/else	# go somewhere else
			# do something else
cd $d			# go back to where the script originally started
If you want to print your working directory resolving symbolic links:
$ readlink -m .

<PREV   NEXT>