Search code examples
bashscriptingdirectorycd

'cd' option to change to the previous directory


I remember there was a way to execute the cd command, automatically returning to the previous directory (without an explicit cd ...). Is it possible?


Solution

  • If you just want to go back to the last directory, you can use cd -.

    If you need more places to go back to, try pushd <dir> (instead of cd <dir>) and then you can go back with popd.