官术网_书友最值得收藏!

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
主站蜘蛛池模板: 合水县| 界首市| 冷水江市| 北京市| 怀来县| 且末县| 泾川县| 英德市| 沂水县| 明溪县| 五莲县| 宜兰县| 五莲县| 镇康县| 滨州市| 鄂温| 阳山县| 八宿县| 卓资县| 同江市| 蒙阴县| 政和县| 安义县| 铜鼓县| 西平县| 安远县| 玉山县| 土默特右旗| 通山县| 加查县| 蒲城县| 崇左市| 东阳市| 东明县| 屏南县| 屏东县| 瑞丽市| 衡山县| 虹口区| 工布江达县| 兴义市|