Linux-Praxisbuch/ Shellprogrammierung/ getopt.sh
Erscheinungsbild
#!/bin/sh set -- $(getopt "ab:" "$@") || { echo "Anwendung: $(basename $0) [-a] [-b Name] Dateien" 1>&2 exit 1 } echo "Momentan steht in der Kommandozeile folgendes: $*" aflag=0 name=NONE while : do case "$1" in -a) aflag=1 ;; -b) shift; name="$1" ;; --) break ;; esac shift done shift echo "aflag=$aflag / Name = $name / Die Dateien sind $*" # Quelle: https://de.wikibooks.org/wiki/Linux-Praxisbuch:_Shellprogrammierung/getopt.sh # Siehe https://de.wikibooks.org/wiki/Linux-Praxisbuch:_Shellprogrammierung#Parameter.C3.BCbergabe_in_der_Praxis