-1

I pass file to my egrep expression (tcpdump log), then I want to delete all matched lines

Code example:

cat file | tr -d '\000' |egrep -i 'user: | usr: ' --color=auto --line-buffered -B20

How can I delete all matched lines now?

Jakub Pastuszuk
  • 928
  • 4
  • 12
  • 31

2 Answers2

2

Use -v flag

 -v, --invert-match
         Selected lines are those not matching any of the specified patterns.
cat file | tr -d '\000' |egrep -iv 'user: | usr: ' --color=auto --line-buffered -B20 > newfile
Dmitry Shilyaev
  • 713
  • 4
  • 10
0

You can do all that using sed:

sed -iE '/use?r: /d; s/\x0//g' file
anubhava
  • 761,203
  • 64
  • 569
  • 643