dirsdirs [-clpv] [+N | -N]
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. The current directory is always the first directory in the stack.
-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 dirs to print the directory stack with one entry per line.
-vCauses dirs to 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 dirs when invoked without options), starting with zero.
-NDisplays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
popdpopd [-n] [+N | -N]
Removes elements from the directory stack. The elements are numbered from 0 starting at the first directory listed by dirs; that is, popd is equivalent to popd +0.
When no arguments are given, popd removes the top directory from the stack and changes to the new top directory.
Arguments, if supplied, have the following meanings:
-nSuppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+NRemoves the Nth directory (counting from the left of the list printed by dirs), starting with zero, from the stack.
-NRemoves 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, popd uses the cd builtin to change to the directory at the top of the stack. If the cd fails, popd returns a non-zero value.
Otherwise, popd returns an unsuccessful status if an invalid option is encountered, the directory stack is empty, or a non-existent directory stack entry is specified.
If the popd command is successful, Bash runs dirs to show the final contents of the directory stack, and the return status is 0.
pushdpushd [-n] [+N | -N | dir]
Adds a directory to the top of the directory stack, or rotates the stack, making the new top of the stack the current working directory. With no arguments, pushd exchanges the top two elements of the directory stack.
Arguments, if supplied, have the following meanings:
-nSuppresses the normal change of directory when rotating or adding directories to the stack, so that only the stack is manipulated.
+NBrings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-NBrings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
dirMakes dir be the top of the stack.
After the stack has been modified, if the -n option was not supplied, pushd uses the cd builtin to change to the directory at the top of the stack. If the cd fails, pushd returns a non-zero value.
Otherwise, if no arguments are supplied, pushd returns 0 unless the directory stack is empty. When rotating the directory stack, pushd returns 0 unless the directory stack is empty or a non-existent directory stack element is specified.
If the pushd command is successful, Bash runs dirs to 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