I launch script.sh and inside it i want to know what is his name
Is there a standard procedure to know the scripts name ? the idea is to be able to extract the name from teh full path + name contained in $0
Thanks
Yes, $0 will always contain the name of the script. Use basename to extract the name.
basename /some/really/long/dir/path/myscripts/coolscript.sh will print coolscript.sh
So in your script, you could do this:
my_scriptname="$(basename $0)"
my_scriptname=$(basename "$0") would be better.basename $0 will give you the script name
basename doesn't strip extensions unless you ask it to.
basename?readlink)?