[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] bash question
- Subject: [ale] bash question
- From: esoteric at denali.atlnet.com (Wandered Inn)
- Date: Sun, 13 Jun 1999 03:07:42 +0000
Michelangelo Grigni wrote:
> This is a job for the shell IFS variable. Just set it to
> contain a single newline, and then each line will be
> treated as a single input field. Like this:
>
> IFS='
> '
> for f in `cat t1.txt` ; do echo $f ; done
>
> Or like this, without cat:
>
> IFS='
> '
> while read f; do echo $f; done < t1.txt
>
> You may need to restore IFS to its default, depending on
> what else you do in the script.
With the 'while read f;' solution above, you do not need to modify IFS,
since 'read f' will populate the var 'f' with one line at a time.
--
Until later: Geoffrey esoteric at denali.atlnet.com
It should be illegal to yell "Y2K" in a crowded economy.
-- Larry Wall, creator of the programming language Perl