Linux command
pushd 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Push directory to stack
pushd [/path/to/dir]
Swap top two directories
pushd
Push without changing directory
pushd -n [/path/to/dir]
Show directory stack
dirs
Pop from stack
popd
说明
pushd is a shell built-in that changes the current directory while saving the previous directory on a stack. This allows quick navigation between multiple working directories without needing to remember or retype full paths. When called with a directory argument, pushd changes to that directory and pushes the old directory onto the stack. Called without arguments, it swaps the top two directories on the stack. The -n flag adds a directory to the stack without actually changing to it. Use dirs to view the current stack contents, popd to return to the previous directory, and +N or -N notation to rotate to specific stack positions.
参数
- -n
- Add without changing.
- +N
- Rotate Nth entry (from left) to top.
- -N
- Rotate Nth entry (from right) to top.
FAQ
What is the pushd command used for?
pushd is a shell built-in that changes the current directory while saving the previous directory on a stack. This allows quick navigation between multiple working directories without needing to remember or retype full paths. When called with a directory argument, pushd changes to that directory and pushes the old directory onto the stack. Called without arguments, it swaps the top two directories on the stack. The -n flag adds a directory to the stack without actually changing to it. Use dirs to view the current stack contents, popd to return to the previous directory, and +N or -N notation to rotate to specific stack positions.
How do I run a basic pushd example?
Run `pushd [/path/to/dir]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n do in pushd?
Add without changing.