-   Linux - Newbie (
-   -   The cd command can do this? (

zwylinux 10-28-2006 12:44 PM

The cd command can do this?
How can I get back to the previous directory with cd? For example


Now I want to get back to the xx directory,how can i do that with cd?
Obviously I don't want to type such long directory path.

uselpa 10-28-2006 12:46 PM

use the command "cd -"

XavierP 10-28-2006 12:48 PM

No need to type it, use tab completion. So you would do

cd /home/zhou/f<hit tab>/f<hit tab> ....  and so on

zwylinux 10-28-2006 12:49 PM

Many thanks

zwylinux 10-28-2006 12:51 PM

I think cd - is quicker than tab when getting back to previous directory

btmiller 10-28-2006 12:52 PM

You can also use pushd and popd, e.g.:


slackme:~/prog/lanalytics 20$ pwd
slackme:~/prog/lanalytics 21$ pushd ~
~ ~/prog/lanalytics
slackme:~ 22$ pwd
slackme:~ 23$ popd
slackme:~/prog/lanalytics 24$ pwd
slackme:~/prog/lanalytics 25$

uselpa 10-28-2006 12:54 PM

You can do more magic with the CDPATH environment variable. Look here for example.

All times are GMT -5. The time now is 05:29 PM.