- Published on
dirs command-Display records in the Shell directory stack
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
-c | Delete all records in the directory stack |
-l | Display the directories in the stack in full format. When displaying the user's home directory, list the full path instead of "~" |
-n | Display the nth directory from the right (n counts from 0) |
+n | Display the nth directory from the left (n counts from 0) |
-p | List multiple records in the stack with one record per line |
-v | List 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