上QQ阅读APP看书,第一时间看更新
The pwd command
The pwd Bash builtin prints the current working directory for the script to the standard output:
$ pwd /home/bashuser
This information is also available in the PWD environment variable, which can be more flexible to use in scripts.
The working directory for the shell refers to the directory from which all relative paths are based, even if they have multiple levels of directories in them:
$ pwd /home/bashuser/docs $ ls important/doc1.txt important/doc1.txt $ ls doc2.txt doc2.txt $ ls nonexistent ls: cannot access 'nonexistent': No such file or directory
Any path that starts with a forward slash – a leading slash – is instead an absolute path, and resolves independently of the current directory:
$ ls /home/bashuser/important/doc1.txt /home/bashuser/important/doc1.txt $ ls /home/bashuser/doc2.txt /home/bashuser/doc2.txt