From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Simon Content-Type: multipart/alternative; boundary=Apple-Mail-F585AD8D-90A5-4D65-95F0-B1A7F171F185 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Date: Sat, 5 Jan 2019 22:45:13 +0000 Message-Id: References: <6A2B4894-94A0-430A-9A17-84A37F1B4BD6@mapinternet.com> In-Reply-To: <6A2B4894-94A0-430A-9A17-84A37F1B4BD6@mapinternet.com> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] How does one read a file line by line in an rc script? Topicbox-Message-UUID: f295cc50-ead9-11e9-9d60-3106f5b1d025 --Apple-Mail-F585AD8D-90A5-4D65-95F0-B1A7F171F185 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable try cat $1 | while(line=3D`{read}){ echo $line } no doubt you cam do without the cat but i am unsure off hand where to put th= e redirect in and i am not on plan9 just now. -Steve > On 5 Jan 2019, at 10:34 pm, Mack Wallace wrote: >=20 > Another, probably more stupid question - How does one read a text file lin= e by line in an rc script. >=20 > In bash this works: >=20 > #!/bin/bash =20 >=20 > while read line =20 > do =20 > echo $line =20 > done < $1=20 >=20 > I=E2=80=99ve tried: >=20 > #!/bin/rc =20 >=20 > while (line=3D`{read $1}) =20 > { > echo $line =20 > }=20 >=20 > Which produces the first line of the file in an infinite loop. I=E2=80=99v= e tried the -m argument with no output. >=20 >=20 > It=E2=80=99s probably simple, but just can=E2=80=99t seem to find the equi= valent. >=20 > Regards, >=20 > Mack >=20 >=20 >=20 --Apple-Mail-F585AD8D-90A5-4D65-95F0-B1A7F171F185 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
try

cat $1 | while(line=3D`{read}){
echo $line
}
<= span style=3D"background-color: rgba(255, 255, 255, 0);">
no doubt you cam do without the cat but i am unsure off hand w= here to put the redirect in and i am not on plan9 just now.

-Steve

On 5 Jan 2= 019, at 10:34 pm, Mack Wallace <mackbw@mapinternet.com> wrote:

Another, probably more stupid question - How does one read a= text file line by line in an rc script.

In bash this works:

#!/bin/bash  

while read line  
do  
echo $line  
done < $1 

<= /div>
I=E2=80=99ve tried:

#!/bin/rc  

while (line=3D`{read $1})  {
echo $line  

Whi= ch produces the first line of the file in an infinite loop. I=E2=80=99ve tri= ed the -m argument with no output.


It=E2=80=99s probably s= imple, but just can=E2=80=99t seem to find the equivalent.

Regards,

Mack



=
= --Apple-Mail-F585AD8D-90A5-4D65-95F0-B1A7F171F185--