Shellprogrammierung (Linux): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(11 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
== Allgemein == | |||
Hilfe zu eingebauten Kommandos: <code>help <command></code> | |||
Hilfe zu externen Kommandos: <code>man <command></code> | |||
== Status bei Pipes == | |||
Dazu kann die '''Bash'''-Variable <code>PIPESTATUS</code> | |||
<pre> | |||
test ${PIPESTATUS[0]} -eq 0 | |||
</pre> | |||
=== Links === | |||
[https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash] | |||
== 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 | |||
# OPTIND contains the next argument | |||
shift `expr ${OPTIND} - 1` | |||
# alternative: | |||
# shift "$((OPTIND-1))" | |||
echo "command = `basename $0`, first argument = $1" | |||
</pre> | |||
==== Links ==== | |||
[http://openbook.rheinwerk-verlag.de/shell_programmierung/shell_005_007.htm http://openbook.rheinwerk-verlag.de/shell_programmierung/shell_005_007.htm] | |||
=== Fortschrittsanzeige === | === Fortschrittsanzeige === | ||
[Datei:Cursor.sh] | [[Datei:Cursor.sh]] | ||
== Dialog == | |||
=== Links === | |||
[https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script] | |||
== Syntax checken == | |||
<pre> | |||
bash -vn script.sh | |||
</pre> | |||
[https://www.tecmint.com/check-syntax-in-shell-script/ https://www.tecmint.com/check-syntax-in-shell-script/] | |||
== Links == | == Links == |
Aktuelle Version vom 26. Juni 2020, 13:34 Uhr
Allgemein
Hilfe zu eingebauten Kommandos: help <command>
Hilfe zu externen Kommandos: man <command>
Status bei Pipes
Dazu kann die Bash-Variable PIPESTATUS
test ${PIPESTATUS[0]} -eq 0
Links
https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash
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 # OPTIND contains the next argument shift `expr ${OPTIND} - 1` # alternative: # shift "$((OPTIND-1))" echo "command = `basename $0`, first argument = $1"
Links
http://openbook.rheinwerk-verlag.de/shell_programmierung/shell_005_007.htm
Fortschrittsanzeige
Dialog
Links
https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script
Syntax checken
bash -vn script.sh
https://www.tecmint.com/check-syntax-in-shell-script/
Links
http://wiki.bash-hackers.org/commands/classictest
http://linuxint.com/DOCS/Linux_Docs/openbook_shell/index.htm
Zurück zu Ubuntu