# Run the script with the arguments as you would for
# every other command.
# Example: ./script.sh arg1 arg2
#!/bin/sh
echo "argument1: $1"
echo "argument2: $2"
# Output:
# argument1: arg1
# argument2: arg2
# bash arguments cheatsheet
$1, $2, ... -> are the positional parameters.
"$@" -> is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
"$*" -> is the IFS expansion of all positional parameters, $1 $2 $3 ....
$# -> is the number of positional parameters.
$- -> current options set for the shell.
$$ -> pid of the current shell (not subshell).
$_ -> most recent parameter (or the abs path of the command to start the current shell immediately after startup).
$IFS -> is the (input) field separator.
$? -> is the most recent foreground pipeline exit status.
$! -> is the PID of the most recent background command.
$0 -> is the name of the shell or shell script.
#!/bin/bash
SHORT=c:,d:,h
LONG=city1:,city2:,help
OPTS=$(getopt --alternative --name weather --options $SHORT --longoptions $LONG -- "$@")
read variable1
read variable2
...