pushd

Adds the directory to the top of the directory stack.

Summary

pushd [-n] [+N | -N | dir]

The main purpose

Options

-n suppresses changes to the current working directory caused by adding directories.

Parameters

+N (optional): In the list displayed by executing the dirs command without parameters, the Nth directory from the left will be the top of the stack, and the directory in front of it will be moved to the bottom. (counting from 0)

-N (optional): In the list displayed by executing the dirs command without parameters, the Nth directory from the right will be the top of the stack, and the directory in front of it will be moved to the bottom. (counting from 0)

dir (optional): The directory to push.

return value

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

example

# Add a directory to the stack, changing the current working directory.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd ~/Desktop
~/Desktop ~
[user2@pc Desktop]$
#Add a directory to the stack, leaving the current working directory unchanged.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ pushd -n ~/Pictures
~ ~/Pictures ~/Desktop

# Adjust the order.
[user2@pc ~]$ pushd +1
~/Pictures ~/Desktop ~
[user2@pc ~]$ pushd -1
~/Desktop ~ ~/Pictures
[user2@pc ~]$ pushd
~ ~/Desktop ~/Pictures

Notice

Reference link