The directory stack is a list of recently-visited directories. The
pushd
builtin adds directories to the stack as it changes
the current directory, and the popd
builtin removes specified
directories from the stack and changes the current directory to
the directory removed. The dirs
builtin displays the contents
of the directory stack.
The contents of the directory stack are also visible
as the value of the DIRSTACK
shell variable.
dirs
dirs [+N | -N] [-clvp]Display the list of currently remembered directories. Directories are added to the list with the
pushd
command; the
popd
command removes directories from the list.
+N
dirs
when invoked without options), starting
with zero.
-N
dirs
when invoked without options), starting
with zero.
-c
-l
-p
dirs
to print the directory stack with one entry per
line.
-v
dirs
to print the directory stack with one entry per
line, prefixing each entry with its index in the stack.
popd
popd [+N | -N] [-n]Remove the top entry from the directory stack, and
cd
to the new top directory.
When no arguments are given, popd
removes the top directory from the stack and
performs a cd
to the new top directory. The
elements are numbered from 0 starting at the first directory listed with
dirs
; i.e., popd
is equivalent to popd +0
.
+N
dirs
), starting with zero.
-N
dirs
), starting with zero.
-n
pushd
pushd [dir | +N | -N] [-n]Save the current directory on the top of the directory stack and then
cd
to dir.
With no arguments, pushd
exchanges the top two directories.
+N
dirs
, starting with zero) to the top of
the list by rotating the stack.
-N
dirs
, starting with zero) to the top of
the list by rotating the stack.
-n
dir
cd
dir'.
cd
s to dir.
Go to the first, previous, next, last section, table of contents.