1

I'm using this linux grep command

grep -Po 'uc-download-link" [^>]* href="\K[^"]*' | sed 's/\&/\&/g'

that fails on macOS.

In this command, grep -P enables PCRE syntax, while grep -o emits only matched text - see here. Does macOs grep support PCRE.

loretoparisi
  • 15,724
  • 11
  • 102
  • 146
  • 1
    You need `pcregrep`. Possible duplicate of [grep -P no longer works how can I rewrite my searches](https://stackoverflow.com/questions/16658333/grep-p-no-longer-works-how-can-i-rewrite-my-searches) – Wiktor Stribiżew Feb 15 '19 at 10:34
  • @WiktorStribiżew changed the title, since it's not a duplicate, it's specific to macOS, while that referred question it is not. – loretoparisi Feb 15 '19 at 10:36
  • It is still a duplicate. You still need to install the `grep` version for MacOS that supports PCRE regexps. – Wiktor Stribiżew Feb 15 '19 at 10:39
  • @WiktorStribiżew okay, but it does not answer my question. I try to edit it to make more clear. – loretoparisi Feb 15 '19 at 10:40
  • 1
    macOS built-in `grep` does not. Use **homebrew** to install `GNU grep` like this `brew install grep`. – Mark Setchell Feb 15 '19 at 10:46
  • If none of the answers in the duplicate work for you, please [edit] your question to explain why you cannot use Perl or `pcregrep` or any of the other solutions there. You should understand that "duplicate question" on Stack Overflow basically means "the answers to the duplicate question answer this question, too"; so don't get distracted if you are being directed to a duplicate question which is superficially different from yours. – tripleee Feb 15 '19 at 11:00
  • you were right it's a duplicate. Shall I delete or close? – loretoparisi Feb 15 '19 at 11:01

0 Answers0