I feel stupid -- determine the full path to a file
Andrew McNabb
amcnabb at mcnabbs.org
Thu Dec 6 12:49:23 MST 2007
On Thu, Dec 06, 2007 at 10:49:27AM -0700, Michael L Torrie wrote:
>
> then I need foo to be able to get a path that's the real, reduced path,
> without any dots in it. In other words, `pwd`/../bar is not going to
> work.
This is simple and dumb but seems pretty resilient.
########################################################################
#!/bin/bash
# change `pwd` to `pwd -P` to remove symbolic links
pushd `dirname "$1"` >&-
absolute="`pwd`/`basename "$1"`"
popd >&-
echo $absolute
########################################################################
--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868
More information about the PLUG
mailing list