← 返回命令列表

Linux command

popd 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Pop directory from stack

popd

Pop and go to Nth directory

popd +[N]

Pop without changing directory

popd -n

Show directory stack

dirs

说明

popd removes the top directory from the shell's directory stack and changes to the new top directory. This complements pushd, which adds directories to the stack. Use +N or -N to remove a specific entry from the stack by position. The -n flag removes the entry without actually changing the current directory. Use dirs to view the current stack contents. This is a shell built-in available in bash, zsh, and other shells.

参数

+N
Remove Nth entry from left.
-N
Remove Nth entry from right.
-n
Suppress directory change.

FAQ

What is the popd command used for?

popd removes the top directory from the shell's directory stack and changes to the new top directory. This complements pushd, which adds directories to the stack. Use +N or -N to remove a specific entry from the stack by position. The -n flag removes the entry without actually changing the current directory. Use dirs to view the current stack contents. This is a shell built-in available in bash, zsh, and other shells.

How do I run a basic popd example?

Run `popd` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does +N do in popd?

Remove Nth entry from left.