Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-17-2005, 10:36 AM   #1
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Changing behavior of pwd with symlinks

Quick question - is there a way to force pwd to show the full path name even after you've followed a symlink?

i.e. when I do:
laura@cleopatra:~$ ln -s /home/laura/Download/whale-0.2 ./WHALE
laura@cleopatra:~$ cd WHALE
laura@cleopatra:~/WHALE$ pwd

As it is, pwd is rendered rather useless...I know what symlink I followed, what I want to know is what directory I'm in. I'd rather pwd output "/home/laura/Download/whale-0.2."

Does anyknow know if there's a way to do this?
Old 02-17-2005, 04:18 PM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
readlink -f `pwd`
if you want it to be generally applicable, something like
if [ -L `pwd` ]; then readlink -f `pwd`; else pwd; fi

But why does it matter? Wherever you go, there you are.
Old 02-17-2005, 04:46 PM   #3
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
wunderbar :-) thanks!

And mainly because I'm inordinately fond of doing things like "cd ../../../Documents/blah/foo/bar"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
changing a users pwd ALInux Linux - Newbie 1 11-07-2005 01:44 PM
Odd root pwd behavior solstice123 Ubuntu 10 10-11-2005 09:54 PM
reset pwd to root's current pwd? ataraktos2 Linux - General 10 04-26-2005 05:13 AM
changing vi behavior scabies Linux - General 5 10-08-2004 09:03 AM
Changing ls behavior Kitohe Slackware 1 10-03-2004 12:43 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:00 AM.

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