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

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
主站蜘蛛池模板: 通化市| 贡嘎县| 类乌齐县| 绵阳市| 衡阳县| 丰都县| 辽阳市| 五台县| 明水县| 池州市| 潮州市| 中江县| 苏尼特右旗| 长寿区| 察雅县| 启东市| 墨脱县| 连州市| 隆子县| 壤塘县| 乐山市| 隆昌县| 翼城县| 科尔| 靖西县| 鹤壁市| 清水县| 洛南县| 温州市| 将乐县| 水城县| 武安市| 外汇| 武城县| 丹棱县| 泾源县| 齐河县| 丰县| 炎陵县| 昌宁县| 长寿区|