Boris Bielecki Boris Bielecki - 6 months ago 27
Bash Question

AIX sh, how to grep an expression with double quotes in a string?

I need to find in a log, all lines containing a server name.
So I do in my script :

grep $x ./input_log_files.csv >> test.txt


where x contain the server name.

The problem is that this way, I also trap lines that contain the server name in a longer name. To be clear, we have here a AIXserver, and also a virtual server called VAIXserver. So when I search the first one, I get the other one too.
In my log file, the server name in surrounded by double quotes. I'm desperately trying to grep on the server name WITH the double quotes. I also tryed with the commas such as in ,"AIXserver", with no success.

How can I force grep to consider the double quotes ?
I tryed with singl quotes, escape characters ... with no success.

Thx for your help.

Answer
grep -w $x ./input_log_files.csv >> test.txt
Comments