Removes a directory from the directory stack.
popd [-n] [+N | -N]
-n suppresses changes to the current working directory caused by deleting the directory.
+N (optional): In the list displayed by executing the dirs command without parameters, the Nth directory from the left will be deleted. (counting from 0)
-N (optional): In the list displayed by executing the dirs command without parameters, the Nth directory from the right will be deleted. (counting from 0)
Returns successful unless an illegal option is provided or an execution error occurs.
#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
[user2@pc ~]$ pushd -n ~/bin
~ ~/bin ~/Pictures ~/Desktop
# Remove a directory from the directory stack. Deleting the top directory will change the current working directory:
[user2@pc ~]$ popd -2
~ ~/Pictures ~/Desktop
[user2@pc ~]$ popd +1
~ ~/Desktop
[user2@pc ~]$ popd
~/Desktop
[user2@pc Desktop]$
# Remove a directory from the directory stack. Deleting 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 ~]$
The directory stack commands of bash include dirs popd pushd.
The current directory is always at the top of the directory stack.
This command is a built-in bash command. For related help information, please see the help command.
优先推荐相关内容,同时保留你的阅读轨迹和收藏入口。