➜ ~ cat foo.txt
foo bar and baz
random words
foo of the Shire
Legendary bar defeated baz
➜ ~ cat foo.txt | ggrep -P 'foo|(bar.*?baz)'
foo bar and baz
foo of the Shire
Legendary bar defeated baz
И как вы в терминах этой регулярки напишите мне условие:
bar или (baz и foo) ?