LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Changing behavior of pwd with symlinks (https://www.linuxquestions.org/questions/linux-software-2/changing-behavior-of-pwd-with-symlinks-291390/)

rose_bud4201 02-17-2005 09:36 AM

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
/home/laura/WHALE
laura@cleopatra:~/WHALE$

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?
Thanks!
-Laura

slakmagik 02-17-2005 03:18 PM

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.

rose_bud4201 02-17-2005 03:46 PM

wunderbar :-) thanks!

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


All times are GMT -5. The time now is 01:32 PM.