Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: what is grep command for and condition

by aquarium (Curate)
on Aug 17, 2010 at 23:30 UTC ( [id://855649]=note: print w/replies, xml ) Need Help??


in reply to OT: what is grep command for and condition

Make sure you understand your logic..as programming logical operators (and not or) behave sometimes a bit differently to what one might intend or write in spoken language terms. So if you actually want lines that match "MOD" or "DEL" to show up in your output, you need to have a OR operator. Using AND operator will only ever show lines that have both match strings on the same line.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: what is grep command for and condition

Replies are listed 'Best First'.
Re^2: what is grep command for and condition
by anakin30 (Acolyte) on Aug 18, 2010 at 08:37 UTC

    thanks for your explanation. i have a doubt, i have below log file. how to grep only lines which has MOD or DEL only and pipe into a new file. can you please help me. 18/Aug/2010:08:30:39 +0000 conn=108559 op=3375 msgId=3376 - RESULT err=0 tag=120 nentries=0 etime=0 18/Aug/2010:08:30:39 +0000 conn=105611 op=38083 msgId=38084 - EXT oid="1.3.6.1.4.1.42.2.27.9.6.8" 18/Aug/2010:08:30:39 +0000 conn=105611 op=0 msgId=38084 - MOD dn="uid=cpb4tpz1,ou=users,o=dhl.com" 18/Aug/2010:08:30:39 +0000 conn=105611 op=0 msgId=38084 - RESULT err=0 tag=103 nentries=0 etime=0 csn=4c6c19c100020c1d0000 18/Aug/2010:08:30:39 +0000 conn=105611 op=38083 msgId=38084 - RESULT err=0 tag=120 nentries=0 etime=0 18/Aug/2010:08:30:39 +0000 conn=105611 op=38084 msgId=38085 - EXT oid="1.3.6.1.4.1.42.2.27.9.6.5" 18/Aug/2010:08:32:37 +0000 conn=108681 op=0 msgId=95 - DEL dn="cn=asia,cn=mydigi.maxis.com.my,cn=meta-directories,cn=join

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://855649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-23 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found