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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/sh...', 1740452709, '3.17.167.39', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/shell/bash/scripts/index(65): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78