Answers:
cd -
在新旧工作目录之间切换。
avinash @ avinash-Lenovo-IdeaPad-Z500:〜$ cd- bash:cd:未设置OLDPWD avinash @ avinash-Lenovo-IdeaPad-Z500:〜$ cd〜/台式机 avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop $ pwd / home / avinash / Desktop avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop $ cd- / home / avinash avinash @ avinash-Lenovo-IdeaPad-Z500:〜$
也可以看看,
avinash @ avinash-Lenovo-IdeaPad-Z500:〜$ echo $ OLDPWD avinash @ avinash-Lenovo-IdeaPad-Z500:〜$ cd〜/台式机 avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop $ echo $ OLDPWD / home / avinash avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop $ cd d avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop / d $ echo $ OLDPWD / home / avinash / Desktop avinash @ avinash-Lenovo-IdeaPad-Z500:〜/ Desktop / d $
该$OLDPWD
变量存储先前的当前工作目录的路径。
Avinash Raj的答案是完全正确的,但对于手册条目,您可以获取POSIX手册页,然后man cd
可以使用:
sudo apt-get install manpages-posix
man cd
告诉您这一切的是OPERANDS部分:
- When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd
which changes to the previous working directory and then writes its name.
cd
是Bash内置的。因此man bash-builtins
,该文档记录在中,而不是其自己的页面中。这适用于所有其他Bash内置程序。由于bash:
错误消息的前面,您可以说它是内置的。