Display directory stack.
dirs [-clpv] [+N] [-N]
-c Clears the directory stack.
-l Directories starting with ~ in the stack are expanded when displayed.
-p displays each directory in the directory stack on a line basis.
-v displays each directory in the directory stack by line and adds the position number in the stack before each line.
+N (optional): In the list displayed by executing the dirs
command without parameters, the Nth directory from the left will be displayed. (counting from 0)
-N (optional): In the list displayed by executing the dirs
command without parameters, the Nth directory from the right will be displayed. (counting from 0)
Returns successful unless an illegal option is provided or an execution error occurs.
# Add directories to the stack.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ pushd -n ~/Pictures
~ ~/Pictures ~/Desktop
[user2@pc ~]$ pushd -n ~/bin
~ ~/bin ~/Pictures ~/Desktop
# Examples of options and parameters:
[user2@pc ~]$ dirs -l
/home/user2 /home/user2/bin /home/user2/Pictures /home/user2/Desktop
[user2@pc ~]$ dirs -p
~
~/bin
~/Pictures
~/Desktop
[user2@pc ~]$ dirs -v
0 ~
1 ~/bin
2 ~/Pictures
3 ~/Desktop
[user2@pc ~]$ dirs +2
~/Pictures
[user2@pc ~]$ dirs -2
~/bin
[user2@pc ~]$ dirs -c
[user2@pc ~]$ dirs
~