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

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
主站蜘蛛池模板: 定结县| 昭通市| 江孜县| 循化| 墨玉县| 甘孜| 商南县| 甘孜县| 开封市| 涞源县| 美姑县| 杭锦旗| 泸水县| 肇源县| 文昌市| 景谷| 封丘县| 金塔县| 延津县| 修文县| 呼和浩特市| 葵青区| 杭锦旗| 团风县| 昌都县| 泽库县| 夏河县| 蓝田县| 湟中县| 元江| 商城县| 长泰县| 监利县| 太湖县| 武夷山市| 建宁县| 原阳县| 聊城市| 湖口县| 宁强县| 安岳县|