dirs

Display directory stack.

grammar

dirs [-clpv] [+N] [-N]

The main purpose

Options

-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.

Parameters

+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)

return value

Returns successful unless an illegal option is provided or an execution error occurs.

example

# 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
~

Notice