On Tue, 27 Nov 2001, Paul M Foster wrote:
> Here's what I've got: I want to be able to peel off one line at a time
> from a file and process just that line, before going on to the next one.
> I tried something like:
>
> cat myfile | while read ; do
> do_something $REPLY
> done
>
> but it didn't work. I'm trying to avoid awk, sed, perl and such, and
> only do this in bash.
>
> Any clues?
What you need to do is set your inter-field-seperator to only "newline".
For example, the following script will read a file a line at a time and
echo it to output.
===================
IFS='
'
for line in `cat filename`
do
echo $line
done
exit 0
===================
The key to setting IFS is to put a single quote and immediately hit
<enter> before putting another quote. If you put a space in there you
will still break on *both* spaces and newlines when reading in "fields".
Hope that helped.
Paul Braman
aeon@tampabay.rr.com
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:54:36 EDT