Skip to content
The Bash Insectarium

/static/insetario/en/inseto/pushd/

Menu

BSH-027 · Displacements

pushd

A stack of directories: push on the way out, pop on the way back.

Where cd - remembers one step, the stack remembers the whole trail: pushd dir enters the directory and stacks the previous one; popd undoes the last step; dirs shows the path walked.

pushd with no argument swaps the two top directories — the cd - shuttle, inside the stack. Ants do the same: trail marked on the way out, followed home.

$ pushd /var/log
/var/log ~/ninho
$ pushd /etc
/etc /var/log ~/ninho
$ popd
/var/log ~/ninho
Each step stacked; the return, in exact order.