How to read sequentially from a file in SH (not KSH)

Jeffrey B. McGough mcgough at wrdis01.af.mil
Sun Apr 28 07:06:01 AEST 1991


In article <1991Apr27.012336.2732 at shibaya.lonestar.org> afc at shibaya.lonestar.org (Augustine Cano) writes:
>SH does not support this (at least not the one I have).  I have tried:
>
>while read VAR1 VAR2 < $FILENAME; do
>  echo $VAR1 $VAR2
>done

This can be done by...

#! /bin/sh

FILENAME="/foo/bar"

while read VAR1 VAR2
do
{
	echo "$VAR1 VAR2"
}
done < "$FILENAME"

Hope this helps... 
The double quotes are my version of paranoia

I user stuff like this for various admin
tasks all the time...


-- 
Lator,                                       We cheat the other guy,
                                             and pass the savings on to you.
Jeffrey B. McGough
WR-ALC UNIX Systems Administrator                    (mcgough at wrdis01.af.mil)



More information about the Comp.unix.shell mailing list