Directory Stack Builtins
-
dirs -
dirs [-clpv] [+N | -N]
Without options, display the list of currently remembered directories. Directories are added to the list with the
pushdcommand; thepopdcommand removes directories from the list. The current directory is always the first directory in the stack.Options, if supplied, have the following meanings:
-cClears the directory stack by deleting all of the elements.
-lProduces a listing using full pathnames; the default listing format uses a tilde to denote the home directory.
-pCauses
dirsto print the directory stack with one entry per line.-vCauses
dirsto print the directory stack with one entry per line, prefixing each entry with its index in the stack.+NDisplays the Nth directory (counting from the left of the list printed by
dirswhen invoked without options), starting with zero.-NDisplays the Nth directory (counting from the right of the list printed by
dirswhen invoked without options), starting with zero.
-
popd -
popd [-n] [+N | -N]
Remove elements from the directory stack. The elements are numbered from 0 starting at the first directory listed by
dirs; that is,popdis equivalent topopd +0.When no arguments are given,
popdremoves the top directory from the stack and changes to the new top directory.Arguments, if supplied, have the following meanings:
-nSuppress the normal change of directory when removing directories from the stack, only manipulate the stack.
+NRemove the Nth directory (counting from the left of the list printed by
dirs), starting with zero, from the stack.-NRemove the Nth directory (counting from the right of the list printed by
dirs), starting with zero, from the stack.
If the top element of the directory stack is modified, and the -n option was not supplied,
popduses thecdbuiltin to change to the directory at the top of the stack. If thecdfails,popdreturns a non-zero value.Otherwise,
popdreturns an unsuccessful status if an invalid option is specified, the directory stack is empty, or N specifies a non-existent directory stack entry.If the
popdcommand is successful, Bash runsdirsto show the final contents of the directory stack, and the return status is 0. -
pushd -
pushd [-n] [+N | -N | dir]
Add a directory to the top of the directory stack, or rotate the stack, making the new top of the stack the current working directory. With no arguments,
pushdexchanges the top two elements of the directory stack.Arguments, if supplied, have the following meanings:
-nSuppress the normal change of directory when rotating or adding directories to the stack, only manipulate the stack.
+NRotate the stack so that the Nth directory (counting from the left of the list printed by
dirs, starting with zero) is at the top.-NRotate the stack so that the Nth directory (counting from the right of the list printed by
dirs, starting with zero) is at the top.dirMake dir be the top of the stack.
After the stack has been modified, if the -n option was not supplied,
pushduses thecdbuiltin to change to the directory at the top of the stack. If thecdfails,pushdreturns a non-zero value.Otherwise, if no arguments are supplied,
pushdreturns zero unless the directory stack is empty. When rotating the directory stack,pushdreturns zero unless the directory stack is empty or N specifies a non-existent directory stack element.If the
pushdcommand is successful, Bash runsdirsto show the final contents of the directory stack.
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
https://www.gnu.org/software/bash/manual/html_node/Directory-Stack-Builtins.html