It is often helpful to know the absolute path of an executing shell script at run time. Fortunately this is easy to do with the
realpath utility widely available on most Linux distributions.
realpath takes the relative or absolute path of a file as an argument.
$0 is a special bash variable that will expand to the name/relative path of the script being called.
$0 can be passed to
Getting the directory containing of an executing shell script can also be found by using the
dirname utilities together.
echo "printing path of executing script"
echo "printing directory of executing script"
dirname `realpath $0`