Bootstrap FreeKB - Bash (Scripting) - scriptname $0
Bash (Scripting) - scriptname $0

Updated:   |  Bash (Scripting) articles

$0 can be used to get the name of the Bash script being invoked. For example, let's say you have a Bash script named foo.sh. Here is how you would show that foo.sh is the name of the script.

#!/usr/bin/perl
echo scriptname = $0

 

Or, more commonly, scriptname is stored in a constant variable.

#!/usr/bin/perl
SCRIPTNAME=$0
echo scriptname = $SCRIPTNAME

 

Which should return the following.

scriptname = foo.sh

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 5cd2ea in the box below so that we can be sure you are a human.