Top Nav

Bash Directory Stack

Ryan at Level1Techs introduces the Bash Directory Stack:

Quick Reference

The Bash Directory Stack is FILO (First In, Last Out)

pushd /some/dir/path

  • push pwd to stack and change to new directory

dirs

  • list stack

dirs -V

  • list stack vertical with index

popd

  • change directory to directory at position 1 in stack

pushd +n

  • change directory to “n” indexed directory
  • actually a rotate
  • also accepts “-n”

popd +n

  • remove indexed item from stack
  • also accepts “-n”

dirs -c

  • clear stack