[CentOS] mkdir this "." directory

Stephen Harris lists at spuddy.org
Tue Dec 29 18:34:02 UTC 2009


On Tue, Dec 29, 2009 at 10:21:01AM -0800, John R Pierce wrote:

> for instance, say  /home/pierce is a symlink to /home2/pierce  and I'm 
> in /home and go cd pierce, then go cd ..      in *some* unix systems, 
> that cd .. takes me back to home, in others takes me to /home2

It's actually shell dependent, not Unix platform dependent.  Some shells
(eg bash, ksh) perform parsing of the "cd" parameter and so will appear
to back-out of symlinks.  Other (typically older) shells just naively
do a chdir("..") call, which will take you to the real parent directory.

Sometimes both behaviours are useful, so I've created a function "up"

  up()
  {
    cd "`/bin/pwd`/.."
  }

So...

  /home/sweh$ cd public_html
  /home/sweh/public_html$ cd ..
  /home/sweh$ cd public_html
  /home/sweh/public_html$ up
  /autofs/publish$ ls -l /home/sweh/public_html
  lrwxrwxrwx 1 sweh sweh 20 Jun  8  2008 /home/sweh/public_html -> /autofs/publish/public_html/

Symlinks combined with automounters... fun :-)

-- 

rgds
Stephen


More information about the CentOS mailing list