LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-28-2006, 12:44 PM   #1
zwylinux
LQ Newbie
 
Registered: May 2006
Posts: 27

Rep: Reputation: 15
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.
 
Old 10-28-2006, 12:46 PM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
use the command "cd -"
 
Old 10-28-2006, 12:48 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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
 
Old 10-28-2006, 12:49 PM   #4
zwylinux
LQ Newbie
 
Registered: May 2006
Posts: 27

Original Poster
Rep: Reputation: 15
Many thanks
 
Old 10-28-2006, 12:51 PM   #5
zwylinux
LQ Newbie
 
Registered: May 2006
Posts: 27

Original Poster
Rep: Reputation: 15
I think cd - is quicker than tab when getting back to previous directory
 
Old 10-28-2006, 12:52 PM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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$
 
Old 10-28-2006, 12:54 PM   #7
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 47
You can do more magic with the CDPATH environment variable. Look here for example.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration