Remove directories from the directory stack.
popd [-n] [+N | -N]
Removes directories from the directory stack. If the top directory is removed, the current working directory will switch to the new top directory.
Without arguments, removes the top of the directory stack.
-n Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+N (optional): The N-th directory from the left in the list shown by the dirs command without arguments will be removed. (Counting from 0)
-N (optional): The N-th directory from the right in the list shown by the dirs command without arguments will be removed. (Counting from 0)
Returns success unless an invalid option is provided or an execution error occurs.
# Add directories to the stack, current working directory remains unchanged.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ pushd -n ~/Pictures
~ ~/Pictures ~/Desktop
[user2@pc ~]$ pushd -n ~/bin
~ ~/bin ~/Pictures ~/Desktop
# Remove directories from the stack; removing the top directory changes the current working directory:
[user2@pc ~]$ popd -2
~ ~/Pictures ~/Desktop
[user2@pc ~]$ popd +1
~ ~/Desktop
[user2@pc ~]$ popd
~/Desktop
[user2@pc Desktop]$
# Remove directories from the stack; removing the top directory does not change the current working directory:
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ popd -n
~
[user2@pc ~]$
dirs, popd, and pushd.help command for related help information.