SED find lines with 0.0% // ignore lines with 100.0%

I need to β€œfind” all lines with the exact number: 0.0% , but there are numbers in my file as well, such as 100.0%

how can I say "sed" to find EXACT 0.0% and ignore 100.0% something like this: [0].[0]%

my favorit cmd:

 more input.txt | sed -n '/0.0%/p' > output.txt 

inside my file the lines are like this:

 0 packets received, 100.0% packet loss 3 packets received, 0.0% packet loss 

thanks for the help, I know thats basic stuff but, .... ;-)))

+4
source share
1 answer

Here you can use the word boundary:

 sed -n '/\b0\.0%/p' file 3 packets received, 0.0% packet loss (...) 

Or more

 sed -n '/\<0\.0%/p' file 

Or using `grep:

 grep '\b0\.0%' file 

\b or \< is the word boundary, which will ensure that the word boundary is up to 0.0% , therefore avoiding 100% results of the match.

+4
source

All Articles