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*

5
  • awk has regexp pattern matching built-in. you don't need grep here. anywhere that you do grep pattern | awk '{...}' you can (and should) do awk '/pattern/ {...}' Commented Oct 29, 2015 at 21:52
  • @cas,what version of awk can handle the full power of perl-compatible regex that GNU grep can with grep -P? Commented Oct 29, 2015 at 21:56
  • perl -a :). more seriously, grep -P is merely a convenience....there's nothing grep can do with PCRE that it, or awk, can't also do with basic or extended regexp. Commented Oct 29, 2015 at 22:16
  • @cas, pcre grep can handle lookahead and lookbehind assertions among other things, I'm pretty sure these don't exist in BRE and ERE. Not saying one can't get by without these for the most part but when one needs them, one really needs them Commented Oct 29, 2015 at 22:24
  • true. i'm guilty of grep | awk sometimes like most people but in most cases it's not necessary. when it is, i'm likely to just write it in perl. Commented Oct 29, 2015 at 22:28