LinuxCommandLibrary

popd

Pop directory from shell directory stack

TLDR

Pop directory from stack
$ popd
copy
Pop and go to Nth directory
$ popd +[N]
copy
Pop without changing directory
$ popd -n
copy
Show directory stack
$ dirs
copy

SYNOPSIS

popd [options] [+N|-N_]

DESCRIPTION

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.

PARAMETERS

+N

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

CAVEATS

Shell built-in. Works with pushd and dirs.

HISTORY

popd is a shell built-in for directory stack management.

SEE ALSO

pushd(1), dirs(1), cd(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard