Determine the Script Name in Linux

Here I am giving an example of a bash shell script which will determine the script name in Linux using the basename with $0 parameter.

Determine/Get the Script Name in Linux Using Shell Script

The following shell script will determine its name and will assign to a variable at runtime.


sname=$(basename $0)
echo "The script name is : $sname"

Make the File Executable

chmod +x




The script name is :

See also:

Leave a Comment