Where is the Bash Script Running?
Sometimes it’s necessary to figure out where the current bash script is running. Just use the $0
parameter.
command | comment |
---|---|
echo `dirname $0` |
The directory in which the script is running. |
echo `basename $0` |
The name of the script itself (w/o it directory). |