2

I have this list of Portuguese language words https://raw.githubusercontent.com/pythonprobr/palavras/master/palavras.txt. I want to extract only words that do not end in "er" or "ar". I have been trying to apply the methods in the answers to this question Regex not matching words ending with "Impl" but I can't make it work. I've been using the command like this from this answer https://stackoverflow.com/a/22964675/10824251 : $ grep -oP '[A-Z][A-Za-z\d]*(\?<! er) [ [A-Z] [A-Za-z \\ d] * (\? <! er)] ' palavra.txt > output.txt

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125
7beggars_nnnnm
  • 697
  • 3
  • 12

1 Answers1

2

To get all lines that do not end with er and ar, you may use

grep -v '[ea]r$' palavras.txt > output.txt

NOTES:

  • -v - inverts the result, we get all the lines that do not match the regex
  • [ea]r$ - matches e or a, then r at the end of the string
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563