dirs command in Linux with examples
dirs command shell builtin is used to display the list of currently remembered directories. By default, it includes the directory you are currently in. A directory can get into the list via pushd command followed by the dir name and can be removed via popd command.
Syntax:
dirs [-clpv] [+N] [-N]
It is useful for easy and quick flow through the directories on the command line. Suppose you want to go to a directory, you can just use the command pushd dir-name and you will be redirected to that directory. Also, you can simply come back to previous by using command popd
Options:
- c : Clears whole list of remembered directories.
- l : Do not show the path of your home directory in your path-name of a directory.
Example:
/home/vivek/Rocket -> ~/Rocket
- p : Display one entry per line.
- v : Display one entry per line prefixed with positional index starting with 0.
Parameters:
- +N : Displays Nth entry from left.
- -N : Displays Nth entry from right.
Examples:
- Basic Functioning:


- pushd and popd:


- Using Options:

- Using Parameters:
Recommended Posts:
- atd command in Linux with examples
- gs command in Linux with Examples
- df Command in Linux with examples
- rev command in Linux with Examples
- for command in Linux with Examples
- cpp command in Linux with Examples
- cp command in Linux with examples
- cal command in Linux with Examples
- dc command in Linux with examples
- ed command in Linux with examples
- atq command in linux with examples
- ex command in Linux with examples
- ln command in Linux with Examples
- rcp Command in Linux with examples
- yes command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



