LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   The cd command can do this? (https://www.linuxquestions.org/questions/linux-newbie-8/the-cd-command-can-do-this-496401/)

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

$pwd
/home/zhou/fdk/fkd/ai/bbs/linux/fl/bt/mm/xx
$cd
$pwd
/home/zhou

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
Code:

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.:

Code:

slackme:~/prog/lanalytics 20$ pwd
/home/tim/prog/lanalytics
slackme:~/prog/lanalytics 21$ pushd ~
~ ~/prog/lanalytics
slackme:~ 22$ pwd
/home/tim
slackme:~ 23$ popd
~/prog/lanalytics
slackme:~/prog/lanalytics 24$ pwd
/home/tim/prog/lanalytics
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 10:11 PM.