royong
16-07-2009, 09:28
Quick one. If you have spent a lot of time on the command line, you will probably want to keep this in mind. The following command allows you to quickly go back to your previous working directory.
$ cd -
Bash keeps track of your current working directory with the $CWD variable and your previous directory with the $OLDPWD variable. If you type "cd -", bash will substitute it with $OLDPWD.
Here's how it might work
$ pwd
/home/roy
$ cd /var/log/mail
$ pwd
/var/log/mail
$ cd -
/home/roy
$ pwd
/home/roy
$ cd -
Bash keeps track of your current working directory with the $CWD variable and your previous directory with the $OLDPWD variable. If you type "cd -", bash will substitute it with $OLDPWD.
Here's how it might work
$ pwd
/home/roy
$ cd /var/log/mail
$ pwd
/var/log/mail
$ cd -
/home/roy
$ pwd
/home/roy