January 14, 2020

Exclude a word with grep

Exclude a word with grep

Grep a file for everything but a word

To exclude a single word:

the following will print everything but lines containing "excludedword"

grep -v excludedword

The following is a working example of pipeing to grep and exluding each line with the ip address

sudo tcpdump | grep -v

To Exclude multiple words:

grep -v -e word1 -e word2

Piping to grep example:

sudo tcpdump | grep -v -e -e

or on a text file:

grep -v -e -e iplist.txt