Consider i have the below data [3 lines] in my log file.
i want to grep using "Monday" and "Working"
So the only output i expect is
Can you help me with the grep query for Sun Sparc ?
Usage: grep -hblcnsviw pattern file . . .
Consider i have the below data [3 lines] in my log file.
i want to grep using "Monday" and "Working"
So the only output i expect is
Can you help me with the grep query for Sun Sparc ?
Usage: grep -hblcnsviw pattern file . . .
$ cat <<test | awk '/Today/ && /Working/'
Today is Sunday and Holiday for all
Today is Monday and Working day for all
Tomorrow will be Tuesday and Working day
test
Today is Monday and Working day for all
$ cat <<test | grep 'Today.*Working'
Today is Sunday and Holiday for all
Today is Monday and Working day for all
Tomorrow will be Tuesday and Working day
test
Today is Monday and Working day for all
Use egrep
egrep -i {"Monday" | "Working"}
When i tried i got the following error
./analysis_new.sh[11]: syntax error at line 23 : `<<' unmatched
grep "Monday.*Working" file
I get this error ./analysis_new.sh[23]: Working}: not found
My code egrep -i {"Monday" | "Working"} hello.log
When i remove the '{}' i get the below error.
./analysis_new.sh[23]: Working: not found
egrep: syntax error
What operating system and shell are you using?
The output is not as desired.. here is the output
Today is Monday and Working day for all
Tomorrow will be Tuesday and Working day
When i was expecting only Today is Monday and Working day for all
---------- Post updated at 12:39 AM ---------- Previous update was at 12:38 AM ----------
I dont have either bash or ksh. i m using plain sh shell
You said you were using Sun SPARC. You wouldn't answer what operating system you're using, but it is likely either a Solaris operating system or a Linux operating system; both of which either have ksh or bash available for your use. And, the commands Akshay gave you should work with both ksh and bash.
No matter what OS you're using on a Sun SPARC system, the command:
grep Monday your_log_file | grep Working
should work and one or both of the following should also work:
grep -E 'Monday.*Working|Working.*Monday' your_log_file
egrep 'Monday.*Working|Working.*Monday' your_log_file
But, the code Yoda gave you could not produce the output you showed us in Message #8 in this thread unless there is something very strange in your input file that isn't visible in the sample input you posted.
Note that the RE Monday.*Working
will work fine as long as Monday
comes before Working
. The ERE used in the last two grep (and egrep) commands above will work if Monday
comes before or after Working
.