!/bin/bash
Default values for all options
ud_default="default_ud_value"
a_default="default_a_value"
b_default="default_b_value"
c_default="default_c_value"
d_default="default_d_value"
e_default="default_e_value"
f_default="default_f_value"
g_default="default_g_value"
h_default="default_h_value"
i_default="default_i_value"
j_default="default_j_value"
k_default="default_k_value"
l_default="default_l_value"
Parse command-line arguments
while getopts ":ud🅰️b:c:d:e:f:g:h:i:j:k:l:" opt; do
case $opt in
u)
ud="$ud_default" # Use default value for -u
;;
d)
ud="$OPTARG" # Use provided value for -d
;;
a)
a="$OPTARG" # Use provided value for -a
;;
b)
b="$OPTARG" # Use provided value for -b
;;
c)
c="$OPTARG" # Use provided value for -c
;;
d)
d="$OPTARG" # Use provided value for -d
;;
e)
e="$OPTARG" # Use provided value for -e
;;
f)
f="$OPTARG" # Use provided value for -f
;;
g)
g="$OPTARG" # Use provided value for -g
;;
h)
h="$OPTARG" # Use provided value for -h
;;
i)
i="$OPTARG" # Use provided value for -i
;;
j)
j="$OPTARG" # Use provided value for -j
;;
k)
k="$OPTARG" # Use provided value for -k
;;
l)
l="$OPTARG" # Use provided value for -l
;;
?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
😃
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
Use default values if no arguments were provided
ud=${ud:-$ud_default}
a=${a:-$a_default}
b=${b:-$b_default}
c=${c:-$c_default}
d=${d:-$d_default}
e=${e:-$e_default}
f=${f:-$f_default}
g=${g:-$g_default}
h=${h:-$h_default}
i=${i:-$i_default}
j=${j:-$j_default}
k=${k:-$k_default}
l=${l:-$l_default}
Now you can use the variables 'ud', 'a', 'b', etc. in your script
echo "ud: $ud"
echo "a: $a"
echo "b: $b"
echo "c: $c"
echo "d: $d"
echo "e: $e"
echo "f: $f"
echo "g: $g"
echo "h: $h"
echo "i: $i"
echo "j: $j"
echo "k: $k"
echo "l: $l"