Revision history for Bash


Revision [25888]

Last edited on 2018-01-12 22:08:54 by ToBo
Additions:
==a==Console colors==a==
[[PythonBashConsoleColor Bash color output in Python]]


Revision [24763]

Edited on 2017-08-02 22:10:35 by ToBo
Additions:
echo "Test with unknown command should fail."
foofoo 2> /dev/null
exitcode=$?
echo $exitcode
if [ $exitcode -ne 0 ]; then
echo "Error"
echo "OK"
echo " "
echo "Test with successfull executed command should return 0."
ls > /dev/null
exitcode=$?
echo $exitcode
if [ $exitcode -ne 0 ]; then
echo "Error"
echo "OK"
Result
Test with unknown command should fail.
127
Error
Test with successfull executed command should return 0.
0
OK


Revision [24762]

Edited on 2017-08-02 21:54:21 by ToBo
Additions:
==a==Create enumerated files and directories==a==
mkdir dir{0..9}
dir0
dir1
dir2
...
dir9


Revision [22455]

Edited on 2015-11-14 12:09:41 by ToBo
Additions:
==a==BASH error handling==a==
Deletions:
==a==BASH error handlin==a==


Revision [21995]

Edited on 2015-10-07 22:26:20 by ToBo
Additions:
==a==BASH error handlin==a==
Exit status
%%$?%%


Revision [21994]

Edited on 2015-10-07 21:46:38 by ToBo
Additions:
Endless loop
while [ true ]
...


Revision [21993]

Edited on 2015-10-07 21:36:52 by ToBo
Additions:
Mit IF
if [ "$a" -gt "0" ]; then
echo 'true'
else
echo 'false'
fi


Revision [21550]

Edited on 2015-08-06 18:15:29 by ToBo
Additions:
==a==Parallel processing in BASH==a==
http://stackoverflow.com/questions/13296863/difference-between-wait-and-sleep
sleep 10 &
wait


Revision [20746]

Edited on 2015-02-19 01:40:39 by ToBo
Additions:
Besser
zahl=1
zahl=$(( $zahl + 1 ))


Revision [18168]

Edited on 2014-02-08 15:34:12 by ToBo
Additions:
==a==While==a==
while [ condition ]
do
[Kommandos]
done


Revision [15785]

Edited on 2013-03-17 02:31:28 by ToBo
Additions:
Zahl inkrementieren
String zuweisen
set A=Dies ist ein Test
echo %A%
set B=%A%
echo %B%
Pfad hinzufügen
set PATH=%PATH%;C:\rnsget
Set alle Variablen auflisten
set
if [ "$a" -eq "$b" ]
if [ "$a" -ne "$b" ]
if [ "$a" -gt "$b" ]
if [ "$a" -ge "$b" ]
if [ "$a" -lt "$b" ]
if [ "$a" -le "$b" ]
(("$a" < "$b"))
(("$a" <= "$b"))
(("$a" > "$b"))
(("$a" >= "$b"))
if [ "$a" = "$b" ]
if [ "$a" == "$b" ]
if [ "$a" != "$b" ]
This operator uses pattern matching within a [[ ... ]] construct.
if [[ "$a" < "$b" ]]
if [ "$a" < "$b" ]
Note that the "<" needs to be escaped within a [ ] construct.
if [[ "$a" > "$b" ]]
if [ "$a" > "$b" ]
Note that the ">" needs to be escaped within a [ ] construct.
See Example 26-11 for an application of this comparison operator.
exp1 -a exp2 returns true if both exp1 and exp2 are true.
exp1 -o exp2 returns true if either exp1 or exp2 are true.


This is identical in effect to -e. It has been "deprecated," and its use is discouraged.
This test option may be used to check whether the stdin ([ -t 0 ]) or stdout ([ -t 1 ]) in
a given script is a terminal.
If a directory has the sgid flag set, then a file created within that directory belongs to the group that
owns the directory, not necessarily to the group of the user who created the file. This may be useful
for a directory shared by a workgroup.
file f1 is newer than f2
file f1 is older than f2
files f1 and f2 are hard links to the same file
Deletions:
if [ "$a" -eq "$b" ]
if [ "$a" -ne "$b" ]
if [ "$a" -gt "$b" ]
if [ "$a" -ge "$b" ]
if [ "$a" -lt "$b" ]
if [ "$a" -le "$b" ]
(("$a" < "$b"))
(("$a" <= "$b"))
(("$a" > "$b"))
(("$a" >= "$b"))
if [ "$a" = "$b" ]
if [ "$a" == "$b" ]
if [ "$a" != "$b" ]
This operator uses pattern matching within a [[ ... ]] construct.
if [[ "$a" < "$b" ]]
if [ "$a" < "$b" ]
Note that the "<" needs to be escaped within a [ ] construct.
if [[ "$a" > "$b" ]]
if [ "$a" > "$b" ]
Note that the ">" needs to be escaped within a [ ] construct.
See Example 26-11 for an application of this comparison operator.
exp1 -a exp2 returns true if both exp1 and exp2 are true.
exp1 -o exp2 returns true if either exp1 or exp2 are true.


This is identical in effect to -e. It has been "deprecated," and its use is discouraged.
This test option may be used to check whether the stdin ([ -t 0 ]) or stdout ([ -t 1 ]) in
a given script is a terminal.
If a directory has the sgid flag set, then a file created within that directory belongs to the group that
owns the directory, not necessarily to the group of the user who created the file. This may be useful
for a directory shared by a workgroup.
file f1 is newer than f2
file f1 is older than f2
files f1 and f2 are hard links to the same file


Revision [10534]

Edited on 2009-12-17 05:42:10 by ToBo
Additions:
Zählen
for (( i=4; i<20; i++ )); do echo $i ; done


Revision [8332]

Edited on 2009-04-14 16:05:14 by ToBo
Deletions:
BashLinks


Revision [8331]

Edited on 2009-04-14 16:04:58 by ToBo
Additions:
BashLinks


Revision [6926]

Edited on 2008-12-07 22:18:08 by ToBo

No Differences

Revision [6925]

Edited on 2008-12-07 22:12:12 by ToBo
Additions:
||A < in.txt|| Der Inhalt von in.txt wird als Eingabe an A weitergeleitet||
Deletions:
||A < in.txt|| Der Inhalt von in.txt wird als Eingabe an B weitergeleitet||


Revision [6924]

Edited on 2008-12-07 22:11:33 by ToBo
Additions:
||A "">>"" out.txt|| Die Ausgabe (Fehlermeldungen ausgenommen) von A an den Inhalt der Datei out.txt anhängen||
Deletions:
||A >> out.txt|| Die Ausgabe (Fehlermeldungen ausgenommen) von A an den Inhalt der Datei out.txt anhängen||


Revision [6923]

Edited on 2008-12-07 22:11:17 by ToBo
Additions:
==a==Standard-IO, Error-IO, File-IO und Pipes==a==
||A||Befehl ausführen und auf Beendigung warten ||
||A & || Befehl im Hintergrund ausführen||
||A ; B ||Befehl A ausführen, dann Befehl B||
||(A; B)||Befehle als Gruppe in einer Shell ausgeführt||
||A ""|"" B || Pipe; Die Ausgabe von A wird an B als Eingabe weitergeleitet||
||A $(B) || Die Ausgabe von B wird zu Befehlsargumenten von A||
||A && B || B wird ausgeführt, wenn A ohne Fehler ausgeführt wurde||
||A ""||"" B|| B wird ausgeführt, wenn bei A ein Fehler aufgetreten ist||
||A > out.txt|| Die Ausgabe (Fehlermeldungen ausgenommen) von A in die Datei out.txt schreiben; Die Datei wird überschrieben||
||A >> out.txt|| Die Ausgabe (Fehlermeldungen ausgenommen) von A an den Inhalt der Datei out.txt anhängen||
||A 2> out.txt|| Die Fehlermeldungen von A an in die Datei out.txt schr iben||
||A < in.txt|| Der Inhalt von in.txt wird als Eingabe an B weitergeleitet||
Deletions:
CategoryLinux


Revision [5250]

Edited on 2008-09-08 00:39:29 by ToBo
Additions:
==a==Vordefinierte Variablen==a==
cd `dirname $0` #Change to script directory or any other directory
# do something else
cd $OLDDIR #Change back to old dir
Deletions:
pwd # Print current dir
cd `dirname $0` #Change to script directory
pwd # Print current dir
cd $OLDDIR #Change to old dir
pwd # Print current dir
==a==Vordefiniert==a==


Revision [5249]

Edited on 2008-09-08 00:37:44 by ToBo
Additions:
Merke altes Verzeichnis
OLDDIR=`pwd` #Save current dir
pwd # Print current dir
cd `dirname $0` #Change to script directory
pwd # Print current dir
cd $OLDDIR #Change to old dir
pwd # Print current dir


Revision [5248]

The oldest known version of this page was created on 2008-09-08 00:32:00 by ToBo
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki