Search code examples
regexunixgrepbsd

Is egrep able to output the results of parenthesized subexpressions?


Is egrep able to output the results of parenthesized subexpressions?

I’m using macOS, and when I checked the man page for grep, it mentioned re_format(7). Checking man 7 re_format, I see that it does have support for parenthesized subexpressions and records them in the pmatch array.

However, it isn’t clear how to make egrep output just the parenthesized subexpressions in groups somehow.


Solution

  • No, egrep is not able to output the results of parenthesized subexpressions.