Directory Stack Builtins (Bash Reference Manual)
Up: The Directory Stack [Contents][Index]
6.8.1 Directory Stack Builtins
dirs
dirs [-clpv] [+N | -N]
Display the list of currently remembered directories. Directories are added to the list with the
pushd
command; thepopd
command removes directories from the list. The current directory is always the first directory in the stack.-c
Clears the directory stack by deleting all of the elements.
-l
Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory.
-p
Causes
dirs
to print the directory stack with one entry per line.-v
Causes
dirs
to print the directory stack with one entry per line, prefixing each entry with its index in the stack.+N
Displays the
N
th directory (counting from the left of the list printed bydirs
when invoked without options), starting with zero.-N
Displays the
N
th directory (counting from the right of the list printed bydirs
when invoked without options), starting with zero.
popd
popd [-n] [+N | -N]
When no arguments are given,
popd
removes the top directory from the stack and performs acd
to the new top directory. The elements are numbered from 0 starting at the first directory listed withdirs
; that is,popd
is equivalent topopd +0
.-n
Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+N
Removes the
N
th directory (counting from the left of the list printed bydirs
), starting with zero.-N
Removes the
N
th directory (counting from the right of the list printed bydirs
), starting with zero.
pushd
pushd [-n] [+N | -N | dir]
Save the current directory on the top of the directory stack and then
cd
todir
. With no arguments,pushd
exchanges the top two directories and makes the new top the current directory.-n
Suppresses the normal change of directory when rotating or adding directories to the stack, so that only the stack is manipulated.
+N
Brings the
N
th directory (counting from the left of the list printed bydirs
, starting with zero) to the top of the list by rotating the stack.-N
Brings the
N
th directory (counting from the right of the list printed bydirs
, starting with zero) to the top of the list by rotating the stack.dir
Makes
dir
be the top of the stack, making it the new current directory as if it had been supplied as an argument to thecd
builtin.
Up: The Directory Stack [Contents][Index]