[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: Problem with "for loop" in "here document"
From:       "BuraphaLinux Server" <buraphalinuxserver () gmail ! com>
Date:       2008-07-09 8:18:11
Message-ID: 5d75f4610807090118g378b1693r3642de7afe14f4f0 () mail ! gmail ! com
[Download RAW message or body]

put a backslash in front of the $ so that it is not substituted when
the here document read, but later when you run that code.

On 7/9/08, Mr Aras <arasv@magtech.com.au> wrote:
>
> Hi,
>
> I've been trying to implement a "for loop" in a "here document" but the
> "name" is never assigned to any of the items in the list.
>
> e.g.
>
> #!/bin/sh
> sh <<-EOF
> for word in hello world
> do
>         echo word = $word
> done
> EOF
>
> output is:
> word =
> word =
>
>
> Can someone tell me why this doesn't work? I've been going nuts trying to
> figure this one out.
>
>
> --
> View this message in context:
> http://www.nabble.com/Problem-with-%22for-loop%22-in-%22here-document%22-tp18353951p18353951.html
> Sent from the Gnu - Bash mailing list archive at Nabble.com.
>
>
>
>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic