I’ve been using bash forever and never knew about this:
$ cd -
This will let you change directory to your previous location in the file system. It’s and easy way switch back and forth between two directories.
I’ve been using bash forever and never knew about this:
$ cd -
This will let you change directory to your previous location in the file system. It’s and easy way switch back and forth between two directories.
Mandatory fields are marked as *
3 Responses to “Bash: cd to Last Directory”
Bill August 15, 2010
Awesome! Thanks!
Something I use a lot in bash: !!
it repeats the last command, and you can even add on to it like this:
$ ping example.c
ping: cannot resolve example.c: Unknown host
$ !!om
ping example.com
PING example.com (192.0.32.10): 56 data bytes
64 bytes from 192.0.32.10: icmp_seq=0 ttl=253 time=1.251 ms
Cool! Computers!!!
|Nathan July 18, 2011
I just felt my brain grow from reading those two shortcuts. They’ll be huge timesavers! Thanks guys.
|Josh Beauregard November 23, 2011
You just made my life a little easier. Now to commit it to memory.
|