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

Dominik Schramm dominik.schramm at gmxpro.net
Thu Oct 30 20:00:38 EST 2003


Hi again,

> 
> while read LINE; do echo $LINE; grep "$LINE" master.csv; done < client.txt
> 
> Still no dice. For the record, client.txt has entries like this:
> 
> domain.com
> bank.com
> sample.org
> 
> (That is, the lines are domain names. The worst problem could be the "."
> in each domain name. No "@" signs. No spaces.)

In RegularExpression syntax the dot . means "any character",
so it would match a "." character, too. So, no major problem here.

> 
> I think we/I'm getting closer to a solution. Any other pointers?
> 

Okay, maybe...
If $LINE contained a \n at the end, then the grep expression would, too.
You'd then have to strip away the \n.
I checked that and it doesn't seem to be the case. But maybe you have
another bash version, which does act like this.

What is printed if you run a grep like this?
   grep "bank.com" master.csv

I'm sorry, I have to leave and won't be back before midnight (CET, that is
:-)...
I hope you find the solution!

regards,
dominik



More information about the Techtalk mailing list