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
Asked
Active
Viewed 147 times
2

Casimir et Hippolyte
- 88,009
- 5
- 94
- 125

7beggars_nnnnm
- 697
- 3
- 12
-
1What language or tool or regex engine do you use to do that? – Casimir et Hippolyte Oct 30 '19 at 21:52
-
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` – 7beggars_nnnnm Oct 30 '19 at 21:58
-
1Use `grep -v '[ea]r$' palavra.txt > output.txt`. I believe you want to get all *lines* that do not end with `er` and `ar`, right? – Wiktor Stribiżew Oct 30 '19 at 21:59
-
@WiktorStribiżew Thankx! It worked correctly. – 7beggars_nnnnm Oct 30 '19 at 22:01
1 Answers
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$
- matchese
ora
, thenr
at the end of the string

Wiktor Stribiżew
- 607,720
- 39
- 448
- 563