home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!highlite!dlreed
- From: dlreed@highlite.uucp (David L. Reed)
- Subject: Re: Reading a line from a file in Bourne
- Message-ID: <1992Dec14.233439.4054@highlite.uucp>
- Organization: Gotham Communications Research
- References: <SHUTTON.92Dec11112920@fokker.union.indiana.edu> <SHUTTON.92Dec11223107@fokker.union.indiana.edu>
- Distribution: usa
- Date: Mon, 14 Dec 1992 23:34:39 GMT
- Lines: 33
-
- shutton@fokker.union.indiana.edu (Scott K. Hutton) writes:
-
- >I've received a lot of good advice, both through e-mail and followups.
- >The bottom line (while I did receive lots of innovative solutions) is
- >to do something akin to the following:
-
- >#!/bin/sh
- >cat myfile |
- >while read LINE
- >do
- > echo a full line: $LINE
- >done
-
- This is good, but avoid a pipe if possible.
-
- The alternative that has worked best for me is to let while take
- stdin directly from the file:
-
- #!/bin/sh
- while read LINE
- do
- echo a full line: $LINE
- done < myfile
-
- >"read" apparently has a significant return value--major goof on my
- >part for failing to check this.
-
- >-S
- --
- David L. Reed: dlreed@gotham.com dlreed@highlite.uucp uunet!highlite!dlreed
- Come join us at highlite... Public Access Unix for DC/MD/VA.
- D.C. Metro (301)924-5998, Comms set to 8N1. login: guest passwd: guest
- Taking calls at 1200/2400/9600+ (V.32bis/V.42bis w/error correction)
-