home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!caen!snark
- From: snark@chiasmus.engin.umich.edu (Mark Van Antwerp)
- Subject: Re: Reading a line from a file in Bourne
- Message-ID: <LdR=s!B@engin.umich.edu>
- Date: Fri, 11 Dec 92 18:59:01 EST
- Organization: University of Michigan (CAEN)
- Distribution: usa
- References: <SHUTTON.92Dec11112920@fokker.union.indiana.edu> <GUENTHER.92Dec11140649@quelle.stolaf.edu>
- Originator: snark@chiasmus.engin.umich.edu
- Nntp-Posting-Host: chiasmus.engin.umich.edu
- Lines: 36
-
-
- Scott K. Hutton wrote:
- -------------------------
- 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?
- ------------------------
-
- Well, the reason it does that is do to the IFS in the bourne
- shell. You can change the IFS or use another command.
-
- To change IFS, do:
-
- IFS="
- "
- This changes it to a newline.
-
- Some other ideas are using read or awk.
-
- -snark
-
- p.s. I think IFS defaults to a space and/or tab.
-