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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.