Shellprogrammierung (Linux): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 1: | Zeile 1: | ||
== Testscripte == | == Testscripte == | ||
=== getops === | |||
<pre> | |||
#!/bin/bash | |||
while getopts "l:m" OPTION &>/dev/null | |||
do | |||
case "$OPTION" in | |||
l) echo "Option l with argument $OPTARG";; | |||
m) echo "Option m without argument";; | |||
*) echo "Wrong option $OPTION";; | |||
esac | |||
done | |||
# OPTING contains the next argument | |||
shift `expr ${OPTIND} - 1` | |||
echo "command = `basename $0`, first argument = $1" | |||
</pre> | |||
=== Fortschrittsanzeige === | === Fortschrittsanzeige === |
Version vom 25. Februar 2017, 16:21 Uhr
Testscripte
getops
#!/bin/bash while getopts "l:m" OPTION &>/dev/null do case "$OPTION" in l) echo "Option l with argument $OPTARG";; m) echo "Option m without argument";; *) echo "Wrong option $OPTION";; esac done # OPTING contains the next argument shift `expr ${OPTIND} - 1` echo "command = `basename $0`, first argument = $1"
Fortschrittsanzeige
Links
http://wiki.bash-hackers.org/commands/classictest
http://linuxint.com/DOCS/Linux_Docs/openbook_shell/index.htm
Zurück zu Ubuntu