Quote:
Originally Posted by
santoshdrkr
The line
print "YES : $(cat count.xls|grep -i '~Y or YES~' | wc -l)">>final_count.xls
is working correctly for me as i have data delimited by ~ and I am looking for occurances of field Y or YES.
No, you are not. This
grep command will only match lines that contain the exact string
~Y or YES~. If you want to match any line that contains
~Y,
~y,
YES~,
YEs~,
YeS~,
Yes~,
yES~,
yEs~,
yeS~, or
yes~ you need something much more like what protocomm suggested (but for EREs with alternation, you need
egrep instead of
grep).
Please describe in English exactly what you are hoping to match with your grep commands. Note also since you apparently aren't matching complete fields, your search for
NO will also match the lines containing
No Resonse. I.e., the lines containing
~NO~ and the lines containing
~No Response~ will both be counted as matching
~NO when doing case insensitive matches. Is that really what you want?