February 26, 2009

Full path of a bash script

What I needed was the full path of a running script

echo $0

Returns the relative path of the file.. so no go there.. but:

MY_PATH=$(readlink -f $0)
echo $MY_PATH

WORKS!!

thanks: Andy Skelton