488889
247
Zoom out
Zoom in
Vorherige Seite
1/284
Nächste Seite
18.6 Grouping And Combining Commands
Shells allow you to concatenate and group commands for conditional execution. Each
command returns an exit code which determines the success or failure of its operation.
If it is 0 (zero) the command was successful, everything else marks an error which
is specic to the command.
The following list shows, how commands can be grouped:
Command1 ; Command2
executes the commands in sequential order. The exit code is not checked. The
following line displays the content of the le with cat and then prints its le
properties with ls regardless of their exit codes:
cat filelist.txt ; ls -l filelist.txt
Command1 && Command2
runs the right command, if the left command was successful (logical AND). The
following line displays the content of the le and prints its le properties only,
when the previous command was successful (compare it with the previous entry
in this list):
cat filelist.txt && ls -l filelist.txt
Command1 || Command2
runs the right command, when the left command has failed (logical OR). The fol-
lowing line creates only a directory in /home/wilber/bar when the creation of the
directory in /home/tux/foo has failed:
mkdir /home/tux/foo || mkdir /home/wilber/bar
funcname(){ ... }
creates a shell function. You can use the positional parameters to access its argu-
ments. The following line denes the function hello to print a short message:
hello() { echo "Hello $1"; }
You can call this function like this:
hello Tux
which prints:
Hello Tux
18.7 Working with Common Flow Constructs
To control the ow of your script, a shell has while, if, for and case constructs.
Bash and Bash Scripts 235
247

Brauchen Sie Hilfe? Stellen Sie Ihre Frage.

Forenregeln

Missbrauch melden von Frage und/oder Antwort

Libble nimmt den Missbrauch seiner Dienste sehr ernst. Wir setzen uns dafür ein, derartige Missbrauchsfälle gemäß den Gesetzen Ihres Heimatlandes zu behandeln. Wenn Sie eine Meldung übermitteln, überprüfen wir Ihre Informationen und ergreifen entsprechende Maßnahmen. Wir melden uns nur dann wieder bei Ihnen, wenn wir weitere Einzelheiten wissen müssen oder weitere Informationen für Sie haben.

Art des Missbrauchs:

Zum Beispiel antisemitische Inhalte, rassistische Inhalte oder Material, das zu einer Gewalttat führen könnte.

Beispielsweise eine Kreditkartennummer, persönliche Identifikationsnummer oder unveröffentlichte Privatadresse. Beachten Sie, dass E-Mail-Adressen und der vollständige Name nicht als private Informationen angesehen werden.

Forenregeln

Um zu sinnvolle Fragen zu kommen halten Sie sich bitte an folgende Spielregeln:

Neu registrieren

Registrieren auf E - Mails für Suse openSUSE 12.2 wenn:


Sie erhalten eine E-Mail, um sich für eine oder beide Optionen anzumelden.


Andere Handbücher von Suse openSUSE 12.2

Suse openSUSE 12.2 Bedienungsanleitung - Englisch - 530 seiten


Das Handbuch wird per E-Mail gesendet. Überprüfen Sie ihre E-Mail.

Wenn Sie innerhalb von 15 Minuten keine E-Mail mit dem Handbuch erhalten haben, kann es sein, dass Sie eine falsche E-Mail-Adresse eingegeben haben oder dass Ihr ISP eine maximale Größe eingestellt hat, um E-Mails zu erhalten, die kleiner als die Größe des Handbuchs sind.

Ihre Frage wurde zu diesem Forum hinzugefügt

Möchten Sie eine E-Mail erhalten, wenn neue Antworten und Fragen veröffentlicht werden? Geben Sie bitte Ihre Email-Adresse ein.



Info