Adds the directory to the top of the directory stack.
pushd [-n] [+N | -N | dir]
Add a directory to the top of the directory stack, switching the current working directory to that directory.
Rotate the directory stack so that the new top of the stack becomes the current working directory.
With no arguments, swaps the first two directories of the directory stack.
-n suppresses changes to the current working directory caused by adding directories.
+N (optional): In the list displayed by executing the dirs
command without parameters, the Nth directory from the left will be the top of the stack, and the directory in front of it will be moved to the bottom. (counting from 0)
-N (optional): In the list displayed by executing the dirs
command without parameters, the Nth directory from the right will be the top of the stack, and the directory in front of it will be moved to the bottom. (counting from 0)
dir (optional): The directory to push.
Returns successful unless an illegal option is provided or an execution error occurs.
# Add a directory to the stack, changing the current working directory.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd ~/Desktop
~/Desktop ~
[user2@pc Desktop]$
#Add a directory to the stack, leaving the current working directory unchanged.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ pushd -n ~/Pictures
~ ~/Pictures ~/Desktop
# Adjust the order.
[user2@pc ~]$ pushd +1
~/Pictures ~/Desktop ~
[user2@pc ~]$ pushd -1
~/Desktop ~ ~/Pictures
[user2@pc ~]$ pushd
~ ~/Desktop ~/Pictures
bash
include dirs popd pushd
.help
command.