Issue
Hi I'm looking for a regular expression for: line of text that does not end with a certain word, let's say it's "abcd"
At first I tried with
.*[^abcd]$
That one doesn't work of course. It matches a line that doesn't end with any of the letters a,b,c or d.
So, in Advanced Grep Topics, I found this expression, but couldn't get it to work:
^(?>.*)(?<=abcd)
->
grep -e "^(?>.*)(?<=abcd)$"
Any idea for the expression I need?
Solution
Have a look at grep
's -v option
grep -v 'abcd$'
If you really meant word rather that just "sequence of characters" then use
grep -v '\babcd$'
\b
meaning "word-boundary"
Answered By - tobyodavies Answer Checked By - Candace Johnson (WPSolving Volunteer)