• Uncategorized

About regex : Ignoring-strings-without-using-the–v-flag

Question Detail

I am trying to use egrep to find lines in a file that contain a certain word, but dont start with that word.

I am currently doing as so…

egrep '^word|word' file.txt

I tried putting it in brackets with the ^ not symbol, but brackets specifiy each letter individually and not a word as a whole.

egrep'^[^word]|word' file.txt

How can I do this, to ignore a certain first word, for example I ignore every The that is at the beginning of a sentence but spot the other ones. Without using the v-flag.

Question Answer

All you need is:

grep '..*word' file


grep -E '.+word' file

to find lines that contain word at a location other than the start of a line.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.