In bash scripts we often need to know in which directory the running script is found especially when the script is in the $PATH and may be occurring in multiple places:
Here is a reliable way to find it out:
Based on this site:
# Absolute path to this script. /home/user/bin/
SCRIPT=$(readlink -f $0)
# Absolute path this script is in. /home/user/bin

%d bloggers like this: