How to read sequentially from a file in SH (not KSH)
Conor P. Cahill
cpcahil at virtech.uucp
Sun Apr 28 12:39:19 AEST 1991
afc at shibaya.lonestar.org (Augustine Cano) writes:
>while read VAR1 VAR2 < $FILENAME; do
> echo $VAR1 $VAR2
>done
use:
while read VAR1 VAR2; do
echo $VAR1 $VAR2
done < $FILENAME
or:
cat $FILENAME |
while read VAR1 VAR2; do
echo $VAR1 $VAR2
done
>but I keep reading the first line in the file over and over. Nothing in
This is because the shell kept reopening the file every time it went to
execute the read.
--
Conor P. Cahill (703)430-9247 Virtual Technologies, Inc.
uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160
Sterling, VA 22170
More information about the Comp.unix.shell
mailing list