Re: while and cats

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Eric \"Shubes\"
Date:  
To: Main PLUG discussion list
Subject: Re: while and cats
Darrin Chandler wrote:
> On Mon, Feb 05, 2007 at 10:59:37AM -0700, Eric Shubes wrote:
>> Nathan Aubrey wrote:
>>> All,
>>> Is there a way to cat something while in a 'while' loop?
>>> example:
>>>
>>> RADIO=(1 2 3)
>>> YEARS=(2007 2006)
>>>
>>> for broadcast in "${RADIO[@]}"; do
>>>   if [ "$broadcast" = "${broadcast#!}" ]; then
>>>     for year in "${YEARS[@]}"; do
>>>       echo "Downloading Network List..."
>>>       ncftpls -x "1r" ftp://username@domain/location/$broadcast/$year/ | 
>>> tee /tmp/$broadcast-$year 2>&1 1>/dev/null
>>>         cat << EOF >> $broadcast-content.html
>>>           Howdy
>>>         EOF
>>>   fi
>>> done

>>>
>>> It gives me an unexpected end of file.
>>> Sorry for any wrapping that might occur.
>>>
>>> nathan
>> echo "Howdy" >>$broadcast-content.html
>> ?
>
> Since he's outputting to html, he probably really does want to use a
> "here document" at some point for formatting.


Oh.

> The trick there, I think, is in the indenting. If never sees the "EOF"
> because it's indented.


I could've told him that. ;)

> Check the manpage for bash to see about alternate
> forms of <<EOF which ignore leading whitespace...
>


Are there any? I hate the way inline files screw up my pretty formatting. :)

--
-Eric 'shubes'
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss