[TriLUG] Bash Symbolic Link Traversal Question
Joseph Mack NA3T
jmack at wm7d.net
Thu Jul 5 12:14:01 EDT 2012
On Thu, 5 Jul 2012, Ken Mink wrote:
> Hey Folks,
> I've been doing a lot of googling on this problem and can't seem to find a
> bash setting to make me happy.
> I do the following:
> mkdir /tmp/dir1
> mkdir /tmp/dir2
> echo "Testing 1 2 3" > /tmp/dir1/test
> ln -s /tmp/dir2 /tmp/dir1/dir2
> cd /tmp/dir1/dir2
> cat ../test
Yes you're in two places with a link. Possibly a step
forward
tpx60:/tmp/dir1/dir2# pwd -L
/tmp/dir1/dir2
tpx60:/tmp/dir1/dir2# pwd -P
/tmp/dir2
tpx60:/tmp/dir1/dir2# dirname $(pwd -P)
/tmp
tpx60:/tmp/dir1/dir2# dirname $(pwd -L)
/tmp/dir1
tpx60:/tmp/dir1/dir2# cat $(dirname $(pwd -L))/test
Testing 1 2 3
Joe
--
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
More information about the TriLUG
mailing list