note
davidrw
OP said <i>I have a module that needs to know its path in order to access another file in the same location.</i> -- the second step of [mod://File::Basename] is to fulfill that requirement (even though he didn't directly ask for it).<br>
<br>
<br>
Other shell (bash) solutions:
<code>
# setup
cd /var/tmp/
touch foo
f='../../var/tmp/foo'
# for just the directory:
d=`(cd ${f%/*} && pwd)`
#or:
d=`dirname $f`
d=`cd $d && pwd`
# for the filename (rel2abs):
d=`dirname $f`
d=`cd $d && pwd`
f=`basename $f`
f=`/bin/ls $d/$f`
</code>
661096
661101