Frage zur bash
Florian Lohoff
f at zz.de
Fri Jan 31 00:49:49 CET 2014
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 at 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 f at zz.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <http://lug-owl.de/pipermail/linux/attachments/20140131/ffd52874/attachment.sig>
More information about the Linux
mailing list