Navigation using puspd, popd and dirs in Linux Console

Sometimes working in console, we have to switch between mulitple folders again and again. if we are restricted to one console than this can be tricky to type full pathnames.

so how to navigate?

pushd : Adds a directory to the top of the directory stack.

popd : remove entries from the top of the directory stack.

dirs : used to display the directory stack


let's discuss their working

I have five folders that i want to switch then:


Notice : we have two ~/Programs in the last because we changed out '~' with '~/Programs' using '$cd'

 In the end  :

$dirs -p : display the directories one by one in new lines
$dirs -l : display the directories with their absolute paths
$dirs -c : clears the directory stack

$pushd -n : rotates the stack left to right and makes nth element at the bottom
$pushd +n : rotates the stack right to left and makes nth element on the top  

$popd : default with no arguments remove the 0th element from the stack
$popd +n : removes  the nth element counting from the left
$popd -n : removes  the nth element counting from the right

Thanks for reading !

No comments:

Post a Comment

Older Post Home