Hallo, Am Mon, 08 Dec 2003, Karl Sinn schrieb:
UPS...
Karl Sinn schrieb:
# Umbenennen / Nummerieren aller Dateien if [ "$1" = "Hallo"] ; then echo "Benutzung: ./rename Dateien Datei-Prefix ErsteNummer" fi
Scheinbar muss zwischen "Hallo" und ] ein Leerzeichen stehen. Ich habs reingemacht, und jetzt gehts auch mit dem if.
Ja. Du solltest 'help test' und 'man test' lesen.
Eine weitere Frage:
In dem Tutorial steht, dass [ ] für alte bashs ist und (( )) für neuere Versionen.
Was benutzt man am besten?
Weder noch. Man sollte if test "$1" = "$Hallo"; then ... fi verwenden. 'if [ ... ]' ist _keine_ shell-syntax, das ist ein builtin- oder ein externer Befehl namens "test"... Ausserdem macht einem die Verwendung von 'test' klarer, was eigentlich ablaeuft, naemlich, dass 'if' schlicht den Exitstatus eines Befehlst testet. Also auch z.B. bei 'if grep -q foo ~/bar' eben den von grep. -dnh -- I think that all good, right thinking people in this country are sick and tired of being told that all good, right thinking people in this country are fed up with being told that all good, right thinking people in this country are fed up with being sick and tired. I'm certainly not, and I'm sick and tired of being told that I am. -- Monty Python