Search notes:

Bash: scripts

Count arguments

The number of arguments with which a script was called is stored in $#.
nof_arguments=$#

echo The script was called with $nof_arguments arguments.
Github repository about-Bash, path: /scripts/count-arguments

Name of the script

$0 stores the name of the script.
echo The name of the script is: $0
echo The script is in the directory $(dirname $0)
Github repository about-Bash, path: /scripts/scriptname-in-dollar-0

See also

zenity to create message boxes in a shell script.
bash

Links

Safer bash scripts with set -euxo pipefail

Index