go to previously visited directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers go to previously visited directory
# 1  
Old 07-14-2005
go to previously visited directory

Is there a way to go back to the previously visited directory?
say im in /dir1 then went to /dir2 and wanted to go back to /dir1.
besides from aliasing every directory i have, i was wondering if there's a way to maybe alias a command to go to the previously visited directory just to make it more convenient especially since i use deep subdirectories.

thanks a lot in advance.
# 2  
Old 07-14-2005
you can use
Code:
cd -

. It will take you only to the last visited directory.

Say you were in /dir1 and then traversed to /dir2.

cd - will take you to /dir1.

You might want to look at pushd and popd as well.

Vino
# 3  
Old 07-14-2005
I think cd - doesn'tn work in all shells.

What shell do you have.
# 4  
Old 07-14-2005
Hammer & Screwdriver

cd - works only with ksh...
command for other shells will be helpful as I too feel requirement of same.
# 5  
Old 07-14-2005
Quote:
Originally Posted by RishiPahuja
cd - works only with ksh...
command for other shells will be helpful as I too feel requirement of same.
Works well with sh also.

Not sure about csh.

Vino
# 6  
Old 07-14-2005
with bash :

cd $OLDPWD
# 7  
Old 07-14-2005
Quote:
Originally Posted by vino
Works well with sh also.

Not sure about csh.

Vino
Yes, works for me in both tcsh and bash, didn't try csh, but I have not seen anyone use plain csh as a login shell for several years.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change the permission to previously used in unix ( chmod )

I have changed the premission of a file to 777. Now I would like to change permission to previously used ( UNDO ). Is there any command ?:confused: (3 Replies)
Discussion started by: frintocf
3 Replies

2. UNIX for Advanced & Expert Users

How to take visited Website log?

I want to take logs for all the visited websites. If any user enter a URL in browser address bar I want to take the log after I want to proceed to access the website and I want to block some websites for my users. I'm using Linux machine. How to do this ? (4 Replies)
Discussion started by: ungalnanban
4 Replies

3. AIX

External Snapshot using previously defined lv

I prefer to assign my own lv names rather than the automatic LV creation that the snapshot Can it be done or is IBM's man page flawed? I am on AIX 6.1 TL 04 Machine type 9133-55A All local SCSI storage. I manually create the lv and attempt to create the snapshot: # mklv -y snapfs99... (2 Replies)
Discussion started by: Skyybugg
2 Replies

4. Linux

Previously run command.

Hi, In HP-UNIX I used to use ! before the command and type a portion of the comnand then if that command was previously run the whole line used to appear. Eg : wc -l samplefile.txt Next if I type !wc And Tab the previously run command would appear on the command prompt. How to achive this... (2 Replies)
Discussion started by: preethgideon
2 Replies

5. UNIX for Dummies Questions & Answers

How to find the details of the previously running process with PID

OS: Unix or Linux I (only) know the pid of the process which was running earlier (say 5 hrs back) but it is not running now. Is there a way I could find the details of that process? (atleast the name of the process). Please let me know. (2 Replies)
Discussion started by: vijay.d
2 Replies

6. UNIX for Dummies Questions & Answers

visited websites

Hi guys, Im just wondering on where a network admin would view a list of visited websites in unix and where to block some websites? (3 Replies)
Discussion started by: jake2891
3 Replies

7. UNIX for Advanced & Expert Users

how to erase files from a tape used previously on Windows operating system

hi all Please may you help. I want to put my unix application backup files using tar cv8 * from a specific folder e.g /u1/sage With new tapes SONY 4mm-DL 90m i can do it with no problem at all. Now I have run out of tapes and I need to use the same kind but they were once used to back... (5 Replies)
Discussion started by: isaac
5 Replies

8. UNIX for Dummies Questions & Answers

remember last visited line in vim

hi, I know we can do this; but dont know how.. I open a file using vim..browse thru it and then say :wq after reaching some line; The next time I open the same file, I want vim to position the cursor on the line where I left last time; anyone? (2 Replies)
Discussion started by: spopuri
2 Replies
Login or Register to Ask a Question