Reputation: 7471
I run a command that produce lots of lines in my terminal - the lines are floats.
I only want certain numbers to be output as a line in my terminal.
I know that I can pipe the results to egrep:
| egrep "(369|433|375|368)"
if I want only certain values to appear. But is it possible to only have lines that have a value within ± 50 of 350 (for example) to appear?
Upvotes: 0
Views: 88
Reputation: 207668
I would go with awk
here:
./yourProgram | awk '$1>250 && $1<350'
e.g.
echo -e "12.3\n342.678\n287.99999" | awk '$1>250 && $1<350'
342.678
287.99999
Upvotes: 0
Reputation: 456
grep
matches against string tokens, so you have to either:
grep -E [34]..
, with appropriate additional context added to the expression and a number of additional .
s equal to your floating-point precision)I'd strongly encourage you to take the second option.
Upvotes: 1