Skip to main content
The 2024 Developer Survey results are live! See the results

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.

13
  • 33
    As a note, OSX Mountain Lion no longer supports PCRE in grep.
    – yincrash
    Commented Aug 9, 2012 at 15:20
  • 7
    Ask your sysadmin to install gsed. You'd be amazed at what a few donuts will get you...
    – avgvstvs
    Commented Dec 11, 2012 at 13:08
  • 3
    Note that you might need to prefix the '(' and ')' with '\', I don't know why.
    – lumbric
    Commented May 9, 2014 at 9:40
  • 9
    @lumbric: If you're referring to the sed example, if you use the -r option (or -E for OS X, IIRC) you don't need to escape the parentheses. The difference is that between basic regular expressions and extended regular expressions (-r). Commented May 9, 2014 at 10:51
  • 2
    I found the accepted answer confusing b/c it incorporated a large regexp with the example, making it hard to extract the needed information: In sed you must escape parenthesis \(.*\), access capture groups with \1, \2, ect.. Commented May 20, 2018 at 16:58