Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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?

like image 371
Roberto Aloi Avatar asked Mar 09 '10 11:03

Roberto Aloi


2 Answers

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.

like image 153
Aaron Digulla Avatar answered Oct 01 '22 23:10

Aaron Digulla


Found! I can execute it as a sub-shell.

A command list embedded between parentheses runs as a subshell.

SOURCE: http://tldp.org/LDP/abs/html/subshells.html

like image 30
Roberto Aloi Avatar answered Oct 01 '22 23:10

Roberto Aloi