Linuxstar
Published on

dirs command-Display records in the Shell directory stack

Jonas

Jonas

1 min read

The dirs command is used to display the stack records in the Shell directory. When no option is added, all directories in the current Shell command stack are displayed. When displaying, the left side is the newly added directory.

Syntax: dirs [parameter]

Command parameters
-cDelete all records in the directory stack
-lDisplay the directories in the stack in full format. When displaying the user's home directory, list the full path instead of "~"
-nDisplay the nth directory from the right (n counts from 0)
+nDisplay the nth directory from the left (n counts from 0)
-pList multiple records in the stack with one record per line
-vList all records in the stack with one record per line, and add a serial number to each line (numbering starting from 0)
Example

Display the records in the Shell directory stack:

[root@linuxstar ~]# dirs

Display the contents of the Shell directory stack, one record per line:

[root@linuxstar ~]# dirs -p 

Display the contents of the Shell directory stack, one record per line, plus the serial number:

[root@linuxstar ~]# dirs -v

Delete records in the Shell directory stack:

[root@linuxstar ~]# dirs -c