BASH Shell Programmierung

(Last Updated On: 10. Oktober 2018)
synchiropus_splendidus

synchiropus_splendidus

Bash is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.
siehe GNU-BASH und GNU bash manual.

Voraussetzung ist natürlich das man die Grundbefehle kennt, siehe auch 1.103.1 Arbeiten auf der Kommandozeile und die Kommentare dort.

Eine sehr hilfreiche Seite ist Bash-Befehle und Bash-Programmierung. Dort findet man nicht nur Befehle und Lektionen zur Bash-Programmierung, sondern auch Informationen zu iptables und generell zur Administration eines Linux Systems (empfehlenswert).

Learnig Shell (englisch) hat sich ebenfalls als recht nützliche Quelle erwiesen. Zur Einleitung heißt es dort:

Why bother?

Why do you need to learn the command line anyway? Well, let me tell you a story. Not long ago we had a problem where I used to work. There was a shared drive on one of our file servers that kept getting full. I won’t mention that this legacy operating system did not support user quotas; that’s another story. But the server kept getting full and stopping people from working. One of the software engineers in our company spent the better part of a day writing a C++ program that would look through the directories of all the users and add up the space they were using and make a listing of the results. Since I was forced to use the legacy OS while I was on the job, I installed a version of the bash shell that works on it. When I heard about the problem, I realized I could do all the work this engineer had done with this single line:

du -s * | sort -nr > $HOME/space_report.txt

Graphical user interfaces (GUIs) are helpful for many tasks, but they are not good for all tasks. I have long felt that most computers today do not use electricity. They instead seem to be powered by the „pumping“ motion of the mouse! Computers were supposed to free us from manual labor, but how many times have you performed some task you felt sure the computer should be able to do? You ended up doing the work by tediously working the mouse. Pointing and clicking, pointing and clicking.

I once heard an author remark that when you are a child you use a computer by looking at the pictures. When you grow up, you learn to read and write. Welcome to Computer Literacy 101. Now let’s get to work.

Dann möchte ich auf die BASH Programming – Introduction HOW-TO (englisch) Seite hinweisen. Dort findet man u.a. ein Beispiele und ein kleines backup script.

(1014)


History

9 Gedanken zu „BASH Shell Programmierung“

  1. Danke Tscheesy, wirklich eine nützliche Seite. Mir ist aufgefallen, dass der Text in Englisch und die Navigation auf Deutsch gehalten ist. Fast wie bei mir, aber eben nur fast, denn hier ist Deutsch und Englisch manchmal in einer fast grotesken Art und Weise gemischt. Denglisch oder Endeutsch könnte man sagen. 😆

  2. @Dr. Azrael Tods Danke für den Kommentar. Ich glaube so richtige Fans sind eher selten und ich rechne mich bestimmt auch nicht dazu, aber man kommt einfach nicht darum herum, deshalb habe ich mir ein paar gute Seiten gesucht und werde in Zukunft ein wenig üben, denn die Zeit hat man mit ein paar nützlichen scripts dann schnell wieder eingebracht.
    Linux/BSD/Unix bieten wirklich unglaublich mächtige Tools, die man in der shell gut verwenden kann (grep, expr, sed, aqwk…). Mit der Geschwindigkeit bin ich voll und ganz zufrieden, kenne zumindest nichts schnelleres zur Administration eines Systems. Wenn man hingegen Verwaltungstools mit graphischen Oberflächen benutzt (Webmin und Co) merkt man erst wie schnell und effizient so kleine scripts sind. Es ist schon klar, dass sie nicht für Anwendugsprogramme geeignet sind, aber zur Administration sind sie nicht nur unverzichtbar, sondern auch unglaublich effizient und schnell.
    Servus aus Wien, Helmut

  3. Ich bin bestimmt kein ausgesprochener Fan von Bash-Programmierung
    (die Syntax ist grauenvoll, von Geschwindigkeit redet überhaupt erst keiner
    und die Wahrscheinlichkeit ein komplexeres Script nach 2-3 Jahren nochmal zu verstehen bewegt sich irgendwo zwischen Null und noch niedriger)
    Aber die Zahl der kleinen Scripte die ich (jeweils in 1-2 minuten zusammengehackt) hier auf meinem Notebook und auf meinem Server rumliegen habe und die sich über die Jahre angesammelt haben ist enorm.
    Ein unersetzbares Werkzeug für jeden der sich mit Linux/BSD/Unix etwas genauer befasst und Grundwissen für jeden root da draußen.

    Dr. Azrael Tods last blog post..Asterix 2.0 oder die Stadt die Verrückte macht

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert