[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: equivalent of Linux readlink -f in pure bash?
From: |
Bob Proulx |
Subject: |
Re: equivalent of Linux readlink -f in pure bash? |
Date: |
Mon, 8 Aug 2011 21:36:43 -0600 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Jon Seymour wrote:
> readlink -f will fully resolve links in the path itself (rather than
> link at the end of the path), which was the behaviour I needed.
Ah, yes, well, as you could tell that was just a partial solution
anyway.
> It seems cd -P does most of what I need for directories and so
> handling things other than directories is a small tweak on that.
You might try cd'ing there and then using pwd -P to get the canonical
directory name. I am thinking something like this:
#!/bin/sh
p="$1"
dir=$(dirname "$p")
base=$(basename "$p")
physdir=$(cd "$dir"; pwd -P)
realpath=$(cd "$dir"; ls -l "$base" | awk '{print$NF}')
echo "$physdir/$realpath" | sed 's|//*|/|g'
exit 0
Again, another very quick and partial solution. But perhaps something
good enough just the same.
Bob
- equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/08
- Re: equivalent of Linux readlink -f in pure bash?, Bob Proulx, 2011/08/08
- Re: equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/08
- Re: equivalent of Linux readlink -f in pure bash?,
Bob Proulx <=
- Re: equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Bob Proulx, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Bob Proulx, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Jon Seymour, 2011/08/09
- Re: equivalent of Linux readlink -f in pure bash?, Andreas Schwab, 2011/08/09
Re: equivalent of Linux readlink -f in pure bash?, Bernd Eggink, 2011/08/09