File a contains,abcdabcd. defghdefghabcd.defgh. abcdabcd .defghHow can i print all the lines that has the pattern abcd without a dot suffix?It must print,abcddefgh. abcdabcd .defgh #. after any other character is good to goI tried grep 'abcd^[\.]' a, it doesn't work.
grep a pattern that doesn't have dot after it
grep
Using ^ outside of brackets [...] meaning beginning of line. And you will make mistakes when escaped dot inside brackets, [^\.] means anything except backslash \ and dot ., not only dot .Another note that abcd[^.] won't match abcd at the end of line.So you need:$ grep -E 'abcd([^.]|$)' <fileabcddefgh. abcdabcd .defgh