[ale] bash, full filename
Michael D. Hirsch
mhirsch at nubridges.com
Mon Dec 1 16:48:50 EST 2003
On Saturday 29 November 2003 01:49 pm, David Corbin wrote:
> How can I take a filename (which may or may not be relative) and convert it
> to be a fully qualified filename, in bash?
This was kinda fun:
fullname ()
{
name=$1
filename=`basename $name`
dirname=`dirname $name`
cd $dirname > /dev/null
fulldir=`pwd`
cd - > /dev/null
echo "${fulldir}/`basename $1`"
}
Now you can use it:
[1038] hirsch>fullname bin/limewire
/home/hirsch/bin/limewire
[1039] hirsch>fullname /usr/bin/xpdf
/usr/bin/xpdf
[1040] hirsch>fullname ../../usr/bin/xpdf
/usr/bin/xpdf
[1041] hirsch>fullname ./Admin
/home/hirsch/Admin
Michael
More information about the Ale
mailing list