On Thu, Jul 7, 2011 at 5:22 AM, Kamaraju S Kusumanchi
<[email protected]> wrote:
> Consider the following shell script
>
> $cat manual_listing.sh
> #! /bin/sh
>
> # stanza 1
> for i in "kama" "raju" "k a m a" "r a j u"
> do
> echo $i
> done
>
> # stanza 2
> names='kama raju'
> for i in $names
> do
> echo $i
> done
>
>
> If I run this, I get
> $./manual_listing.sh
> kama
> raju
> k a m a
> r a j u
> kama
> raju
>
> I am wondering if there is a way to rewrite the names variable in stanza2
> such that the output from stanza 1 and stanza 2 are the same.
You can use array variables if you want:
names=("kama" "raju" "k a m a")
for i in "${names[@]}"
do
echo $i
done
Search "[@" (probablily escaping both) inside man bash
Regards,
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive:
http://lists.debian.org/CAL5yMZT8Bu14N1nt_tefMJNn5mHWK3nGtJ6fHnyMi+k=obo...@mail.gmail.com