On Thu, Jan 30, 2014 at 09:50:21AM +0100, Ralph Meyer wrote:
> Hallo,
> 
> ich hätte mal eine Bash Frage.
> 
> Ich habe eine Variable LIST
> 
> LIST="blau gelb rot"
> 
> Jetzt wollte ich in einer For Schleife die einzelnen Wörter ausgeben.
> 
> Das geht mit :
> 
> --------------------------------
> #!/bin/bash
> 
> LIST="blau gelb rot"
> 
> set junk $LIST
> 
> shift

kein set kein shift

for i in $LIST; do
        echo $i
done

Hat den Vorteil das man sich die $0... nicht kaputt macht.

Ach ja - Ich empfehle einfach mal so ein script mit -x zu starten 
dann sieht man ja was los ist:

flo@p2:~$ bash -x i
+ LIST='blau gelb rot'
+ for i in '$LIST'
+ echo blau
blau
+ for i in '$LIST'
+ echo gelb
gelb
+ for i in '$LIST'
+ echo rot
rot

Flo
-- 
Florian Lohoff                                                 [email protected]

Attachment: signature.asc
Description: Digital signature

-- 
Linux mailing list [email protected]
subscribe/unsubscribe: http://lug-owl.de/mailman/listinfo/linux
Hinweise zur Nutzung: http://www.lug-owl.de/Mailingliste/hints.epo

Antwort per Email an