Get Directory of Bash Script Being Executed
I needed a quick way to get the directory of the current bash script being executed and a little googling led me to this elegant little bit:
# Absolute path to this script. /home/user/bin/foo.sh SCRIPT=$(readlink -f $0) # Absolute path this script is in. /home/user/bin SCRIPTPATH=`dirname $SCRIPT`
via fritzthomas
Let's talk
I'm one of the founders of Venmo. If you liked this essay/experiment -- or didn't -- @ me.