• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 891
  • Last Modified:

perl paragraph mode search


I use a perl command to search a group of lines like:

perl -00 -ne 'print if /keyword/' txtfile1

how can i make this find the groups that does NOT contain the key word i use.
In other words    "if Not"

Thanks,
0
bt707
Asked:
bt707
  • 3
  • 2
1 Solution
 
ozoCommented:
perl -00 -ne 'print unless /keyword/' txtfile1

perl -00 -ne 'print if ! /keyword/' txtfile1
0
 
bt707Author Commented:
thanks ozo
0
 
manav_mathurCommented:
Wouldnt a simple 'grep' be effeicient in this case.....
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ozoCommented:
perl -00 -e 'print grep{not /keyword/}<>' txtfile1
would need to read the entire file into memory before printing anything.
0
 
manav_mathurCommented:
I meant a Unix grep. That's supposed to be more optimized for this kind of things....no??
0
 
ozoCommented:
Yes, although Unix grep searches for lines, not paragraphs.
You could convert paragraphs to lines | grep | convert lines back to paragraphs
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now