开发者

Delete lines containing a range pattern in 4th column

开发者 https://www.devze.com 2023-01-02 09:44 出处:网络
In a file 4th column contai开发者_开发问答ns a floating point numbers dsfsd sdfsd sdfds 4.5 dfsdfsd

In a file 4th column contai开发者_开发问答ns 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


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.


awk:

{ if ($4 > 0.1 || $4 < -0.1) print $0 }
0

精彩评论

暂无评论...
验证码 换一张
取 消