HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

pushd — Place a directory on a stack so it can be accessed later. See also: `popd`, `dirs`. More information

Submitted by: @import:tldr-pages··
0
Viewed 0 times
directoryaccessedcommandcanplacestackclipushd

Problem

How to use the pushd command: Place a directory on a stack so it can be accessed later. See also: popd, dirs. More information: <https://www.gnu.org/software/bash/manual/bash.html#index-pushd>.

Solution

pushd — Place a directory on a stack so it can be accessed later. See also: popd, dirs. More information: <https://www.gnu.org/software/bash/manual/bash.html#index-pushd>.

Switch to directory and push it on the stack:
pushd {{path/to/directory}}


Switch first and second directories on the stack:
pushd


Rotate stack by making the 5th element the top of the stack:
pushd +4


Rotate the stack 4 times to the left (the current directory stays at the top by replacing the 5th element):
pushd -n +4

Code Snippets

Switch to directory and push it on the stack

pushd {{path/to/directory}}

Switch first and second directories on the stack

pushd

Rotate stack by making the 5th element the top of the stack

pushd +4

Rotate the stack 4 times to the left (the current directory stays at the top by replacing the 5th element)

pushd -n +4

Context

tldr-pages: common/pushd

Revisions (0)

No revisions yet.