Reputation: 1398
I have file with ips and port number in the below format
ip:port Written
ip:port Not Written
example : 127.0.0.1:80 Written
I want to grep lines which have Written only , when i tried grep "Written" file.txt
, I got all the lines since written is present is with not written.
I also tried grep -x "Written" file.txt
and grep -E "Written" file.txt
All the methods gave me the same output
OS: MAC OSx
Upvotes: 1
Views: 93
Reputation: 785156
You can use this awk
for non-regex, exact match:
awk '$2 == "Written"' file
127.0.0.1:80 Written
Using gnu -grep
(available on OSX via brew
installer), you can use a negative lookbehind in -P
(PCRE option):
grep -P '(?<!\bNot\h)\bWritten\b' file
Upvotes: 1