Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete lines containing a range pattern in 4th column

In a file 4th column contains a floating point numbers

dsfsd sdfsd sdfds 4.5 dfsdfsd

I want to delete the entire line if the number between -0.1 and 0.1 (or some other range).

Can sed or awk do that for me?

thanks

like image 819
vehomzzz Avatar asked Sep 17 '26 00:09

vehomzzz


1 Answers

I recommend using the "pattern { expression }" syntax:

awk '($4 < -0.1) || ($4 > 0.1) {print}' test.txt

Or, even more concicely:

awk '($4 < -0.1) || ($4 > 0.1)' test.txt

Since {print} is the default action. I've assumed that you have a file "test.txt" containing your data.

like image 138
Stuart Lange Avatar answered Sep 20 '26 19:09

Stuart Lange



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!