Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • @Pratap just to again demonstrate my point that you need to tell us what kind of "pattern matching" you actually want to do, this is doing yet another type of "pattern matching" different from the 2 in my answer (this time it's partial-line regexp matching) which will once again produce the output you show from the input you show in your question. You really should come up with a better example that'll actually test your requirements. Commented Aug 6 at 12:43
  • 2
    .... and if you add -F then it'll become a partial-record, partial-line string match solution, and if you also add -x it'll become a partial-record, full-line string match solution, etc. - all of which will produce the output in the question but would all behave differently given different input. Commented Aug 6 at 13:08
  • @EdMorton, right, but OP did not clarify what exactly he/she want... Commented Aug 6 at 13:26
  • 1
    right, I'm not saying there's any issue with your answer, just pointing out to the OP that their requirements aren't clear and their example needs to be updated to really test whatever their requirements are. Commented Aug 6 at 14:35