Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!uunet!tellab5!vpnet!dattier From: dattier@vpnet.chi.il.us (David W. Tamkin) Newsgroups: comp.unix.shell Subject: Re: How to read sequentially from a file in SH (not KSH) Message-ID: <1991Apr30.205732.10742@vpnet.chi.il.us> Date: 30 Apr 91 20:57:32 GMT References: <1991Apr27.012336.2732@shibaya.lonestar.org> <232@bria.UUCP> <1991Apr29.105329.20148@spider.co.uk> Organization: VPnet Public Access Unix, Villa Park, Illinois 60181-2206 Lines: 26 mark@spider.co.uk (Mark Valentine) wrote in <1991Apr29.105329.20148@spider.co.uk>, quoting two other people: | afc> while read VAR1 VAR2 < $FILENAME; do | afc> echo $VAR1 $VAR2 | afc> done | afc> | afc> but I keep reading the first line in the file over and over. Nothing in | afc> the manual page seems to be usable in this situation. How is this done | afc> under SH? Is it possible? | mike> cat $FILENAME | while read VAR1 VAR2 | mike> do echo $VAR1 $VAR2 | mike> done Mike was onto it, but the extra fork for cat is unnecessary: while read VAR1 VAR2 do echo $VAR1 $VAR2 done < $FILENAME The trick is to redirect the entire loop and not just the read command. Mark Valentine's suggested solution is not needed for this simple case. David Tamkin PO Box 7002 Des Plaines IL 60018-7002 dattier@vpnet.chi.il.us GEnie:D.W.TAMKIN CIS:73720,1570 MCIMail:426-1818 708 518 6769 312 693 0591