Hi,
I have the a file which contains information as mentioned in the below format.

IP:20.20.20.50 DLBytes:0 
IP:0.0.0.0/0 DLBytes:0 
IP:20.20.20.52 DLBytes:0 
IP:0.0.0.0/0 DLBytes:0 
IP:20.20.20.53 DLBytes:187329 
IP:0.0.0.0/0 DLBytes:17176 
IP:0.0.0.0/0 ULBytes:0 
IP:20.20.20.50 ULBytes:0 
IP:0.0.0.0/0 ULBytes:0 
IP:20.20.20.52 ULBytes:0 
IP:0.0.0.0/0 ULBytes:187329 
IP:20.20.20.53 ULBytes:17176

I am using below commands to extract entries which have proper ip address and value of DLBbytes or ULBbytes greater than zero.

grep -v "0.0.0.0" | grep -vw "DLBbytes:0" | grep -vw "ULBbytes:0"
grep -v "0.0.0.0" | grep -vw "DLBbytes:0" | grep -vw "ULBbytes:0"

that means the entries like IP:0.0.0.0/0 DLBytes:0 , IP:20.20.20.xx DLBytes:0 should be discarded.

But i am getting the out put as below

IP:20.20.20.50 DLBytes:0 
IP:20.20.20.52 DLBytes:0 
IP:20.20.20.53 DLBytes:187329 
IP:20.20.20.50 ULBytes:0 
IP:20.20.20.52 ULBytes:0 
IP:20.20.20.53 ULBytes:17176

but if i use

ehco "IP:20.20.20.50 DLBytes:0" | grep -vw "DLBbytes:0" 

its working.

so why its not working in the first case, and how to do it.

Recommended Answers

All 2 Replies

Hello,

You havean extra b in your grep. try this:

grep -v "0.0.0.0" | grep -vw "DLBytes:0" | grep -vw "ULBytes:0"

Sorry, my bad i overlooked it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.