In a very long line I'll summarize with:
I want to print only:
To match the second parenthesis, I exclude the word that follows the third one:
$ grep -oP "\\(.*(?!word).*right"
but Bash interprets the exclamation mark:
-bash: !word: event not found
Protecting the exclamation mark with single quote fails with
grep: missing )
$ grep -oP '\\(.*(?!word).*right' $ grep -oP '\\((?!word)(.*right)'
Protecting the exclamation mark with backslash fails with
grep: unrecognized character after (? or (?-
-P is for Perl regex and
-o is to print only the matching part of a line