How to grep two strings in one line in a file?
I want to grep in a file to find out which line contains the following two strings:
"Mon Sep 14" and "myWeb". How can I do that? I try using grep "Mon Sep 14 && myWeb" but it doesn't do what I want. |
Quote:
Either A or B: Code:
$ cat datafile | grep -P "\b(first|second)\b" Code:
$ cat datafile | grep -P "\bfirst\b" | grep -P "\bsecond\b" |
note that grep takes a filename as an arg, so cat is unneeded
Code:
grep -P "\b(first|second)\b" datafile |
Just a concrete example:
I want to grep the lines which contains string "Aug 27" and "meth='POST' file='/mycom/Calculator'" in a file called "myconfig.conf". How can I do that? |
Quote:
Code:
cat myconfig.conf | grep -P "Aug 27" | grep -P "meth='POST' file='/mycom/Calculator'" |
Quote:
To decide how much clarity of expression matters to newbies, one need only read the interminable threads about the syntax of "xargs", many of which expire more from exhaustion than resolution. |
All times are GMT -5. The time now is 02:07 AM. |