Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!crdgw1!steinmetz!davidsen From: davidsen@steinmetz.ge.com (Wm. E. Davidsen Jr) Newsgroups: comp.unix.questions Subject: Re: Help with strings in Bourne shell Message-ID: <13724@steinmetz.ge.com> Date: 2 May 89 17:05:56 GMT References: <10166@orstcs.CS.ORST.EDU> <1493@vsedev.VSE.COM> <870@marvin.Solbourne.COM> <275@tree.UUCP> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Distribution: usa Organization: General Electric CRD, Schenectady, NY Lines: 34 Cc: stever@tree.uucp In article <275@tree.UUCP> stever@tree.UUCP (Steve Rudek) writes: | By the way, how would: | while read DEFINITION <$INPUTFILE | do | done | | differ from: | while read DEFINITION | do | done <$INPUTFILE | | Or wouldn't it? Redirection on the read command would open and read the INPUTFILE every time throught the loop (ie. read 1st line forever). On the done line the redirect causes all commands in the loop to read their stdin from INPUTFILE. If you want to read successive lines from a file and process them, but not redirect stdin, here's a technique (I invented it myself, but I doubt that it's unique). while read name 0<&3 do : whatever here : stdin is still tty done 3< $INPUTFILE This works with SysV sh as well as ksh (I didn't try BSD, sorry). -- bill davidsen (wedu@crd.GE.COM) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me