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:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.