Reputation: 10685
I have a UNIX log file which contains 1000K lines. Most of the file has lines:
07 Apr 2015 17:54:23.854: Read 0 Messages
I read file using cat filename
I would like to read lines that don't contain a specific text -'Read 0 Messages'
I tried below commands:
cat filename|grep '^{Read 0 Messages}'
cat filename|grep '!{Read 0 Messages}'
Can you advice me correct command?
Upvotes: 7
Views: 24294
Reputation: 289545
grep
can do it:
grep -v "'Read 0 Messages'" file
The -v
option is used to indicate what you do not want to be printed.
From man grep
:
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
Also, note there is no need to cat file | grep '...'
. You can directly say grep '...' file
.
Upvotes: 21