home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!news.stolaf.edu!guenther
- From: guenther@stolaf.edu (Philip A Guenther)
- Subject: Re: Reading a line from a file in Bourne
- In-Reply-To: shutton@fokker.union.indiana.edu's message of Fri, 11 Dec 1992 16:29:20 GMT
- Message-ID: <GUENTHER.92Dec11140649@quelle.stolaf.edu>
- Sender: news@news.stolaf.edu
- Organization: Academic Computing Center, St. Olaf College
- References: <SHUTTON.92Dec11112920@fokker.union.indiana.edu>
- Distribution: usa
- Date: 11 Dec 92 14:06:49
- Lines: 35
-
- In article <SHUTTON.92Dec11112920@fokker.union.indiana.edu> shutton@fokker.union.indiana.edu (Scott K. Hutton) writes:
- This is something that has eluded me for a good while, but now I have
- to find out. How can you read lines (yes, entire lines) sequentially
- in from a file and store them in a variable. For example:
-
- for ITEM in `cat $FILENAME`
- do echo a full line: $ITEM
- done
-
- If you're given a file that contains:
-
- Line one
- Line two
-
- This script would output
-
- a full line: Line
- a full line: one
- a full line: Line
- a full line: two
-
- Any easy answers?
-
- How about:
-
- while read i; do
- echo A line: $i
- done <$FILENAME
-
- Philip Guenther
- --
- guenther@stolaf.edu (Philip Guenther) | The ACC might agree with me,
- Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
- St Olaf College, Northfield, MN 55057-1001 | you never know... :-) :-| :-(
- "Life makes sense? LIFE MAKES SENSE!!? Where do people get these ideas?"-me
-