[Techtalk] Bash builtin "read" isn't working like I expect

Megan Golding mgolding at sdf.lonestar.org
Thu Oct 30 15:39:57 EST 2003


I'm trying to get the Bash command "read" to give me lines from a file:

while read LINE; do echo $LINE; grep $LINE $other-file; done < $first-file

The line from $first-file is echoed back from within the do loop (the echo $LINE bit), so I know the main construct is working (that is, the while loop is going through every line in $first-file). 

Yet, when the grep part runs, STDOUT gets no matching lines between $LINE and $other-file. But I know there are matches.

Here are sample file contents -->

first-file:
bob.com
sample.com

other-file:
hello.com
meg.com
bob.com
test.com
sample.com

I don't know "read" well enough to know why it's acting funky. Googleing turned up bugs in bash itself and some confusing mentions of the IFS variable. I would really appreciate any help. Or general ideas.  

Meg

-- 
Life with Rachel, one mom's journey: http://www.kalamitykat.com

AIM: meganau  Yahoo!: meggolding  email: mgolding at sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org


More information about the Techtalk mailing list