grep based on multiple keywords
September 28th, 2006 mysurface Posted in Text Manipulation, egrep, grep | Hits: 18522 |
grep with multiple keywords need some knowledge of regular expression. But that is not difficult, use (OR).
Let say you want to grep “me” and “you” at world.txt, you do
grep "me\|you" world.txt
You need to put ESCAPE STRING ( \ ) for OR ( | ), else it will treat it as a simbol you want to search instead of regular expression symbol.
You can do this:
grep -E "me|you" world.txt
-E treat symbol as regular expression instead.
or
egrep "me|you" world.txt
Simply use egrep for regular expression grep.
Live Chat!







June 21st, 2007 at 12:09 am
[...] This morning, I asked to analyze log files where I need to grep the lines with two keywords, and the post grep based on multiple keywords doesn’t help much. [...]
June 21st, 2007 at 7:30 am
[...] This morning, I asked to analyze log files where I need to grep the lines with two keywords, and the post grep based on multiple keywords doesn’t help much. [...]
August 10th, 2007 at 1:31 am
[...] grep based on multiple keywords grep with multiple keywords need some knowledge of regular expression. But that is not difficult, use (OR). [...]