pushd
描述
将目录添加到目录堆栈顶部。
- 将目录添加到目录堆栈顶部,切换当前工作目录到该目录。
- 旋转目录堆栈,使堆栈的新顶部成为当前工作目录。
- 没有参数时,交换目录堆栈的前两个目录。
语法
pushd: pushd [-n] [+N | -N | dir]
Add directories to stack.
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory. With no arguments, exchanges the top two directories.
Options:
-n Suppresses the normal change of directory when adding
directories to the stack, so only the stack is manipulated.
Arguments:
+N Rotates the stack so that the Nth directory (counting
from the left of the list shown by `dirs', starting with
zero) is at the top.
-N Rotates the stack so that the Nth directory (counting
from the right of the list shown by `dirs', starting with
zero) is at the top.
dir Adds DIR to the directory stack at the top, making it the
new current working directory.
The `dirs' builtin displays the directory stack.
Exit Status:
Returns success unless an invalid argument is supplied or the directory
change fails.
参数
-n 抑制添加目录引起的当前工作目录变化。
+N 把正数第N个放到栈顶(从栈顶0开始)
-N 把倒数第N个放到栈顶(从栈底0开始)
-n 不切换,只压栈
dir 要推送的目录
例子
# 添加目录到堆栈,改变了当前工作目录。
[smaller ~]$ dirs
~
[smaller ~]$ pushd ~/Desktop
~/Desktop ~
[smaller Desktop]$
# 添加目录到堆栈,当前工作目录不变
[