Friday, October 30, 2009

Linux shell scripts – name of script file

How to get the filename and directory name of the shell script being run:

directoryName=${0%/*} #capture everything before the last /
filename=${0##*/} #capture everything after the last /

No comments: