while

Achim Dreyer adreyer at math.uni-paderborn.de
Fri Nov 23 12:25:03 CET 2001


On Fri, 23 Nov 2001, Hans-Joachim Hoetger wrote:

> Moin
> Ich habe ein Problem mit einem shellscript. Irgendwie
> scheint die bash angefangen zu haben, f=FCr ein 'while' eine
> neue shell aufzumachen. Eine Variable, die ich vor der
> while-shleife setze und in der schleife incrementiere ist
> nach der Schleife wieder auf dem initialen Wert.

.. kein neues feature!

Siehe H. Herold: Shells -> dies war und ist schon immer Bourne Shell
Syntax gewesen!

Abhilfe:
  Umleitung von stdin

> Vielleicht wird das an einem Beispiel deutlicher:
>
> [...]
> FOUND=3D0
> find $LOGDIR -type f -exec grep -l "^alert" {} \; |
> while reade line
> do
>    do_some_really_important()
> 	if test $FOUND -eq 0; then echo $HEADER; fi
>    do_more_important_things()
> 	FOUND=3D`expr $FOUND + 1`
> done

.. benutzt nur lokale variablen!

Ich hatte dazu mal ein kleines FAQ geschrieben, ist aber schon lnge her
und ich finde das nicht mehr..

Regards,
Achim Dreyer

--
THOUGHT FOR THE MONTH:
"Success is the ability to go from failure to failure without losing
your enthusiasm"                      -  Winston Churchill
--
I am Bush of USA. You will be pacified. Resistance is futile.
-----------------------------------------------------------------------
A. Dreyer, UNIX System Administrator and Internet Security Consultant






More information about the Linux mailing list