Wednesday, June 27, 2018

Script to get name of the program running

Use the below line to get name of the program that you are currently running inside the script. This will be mostly used if you want to display how to run the script you have created.

To get current program name inside the script:

script_name=$(basename $0)

You can use it like below:

if [[ $# -eq 0 ]]; then
echo "$script_name -h for more information" 1>&2
exit 254
fi

No comments:

Post a Comment