awk小于或等于不起作用

时间:2016-12-13 05:41:20

标签: awk gawk

tmp.log:

[2016-12-01 00:00:01] ... 
[2016-12-01 00:00:02] .... 
[2016-12-01 00:00:03] ..... 
[2016-12-01 00:00:04] ......

命令:

awk '$0>="[2016-12-01 00:00:01]" && $0<="[2016-12-01 00:00:03]"' tmp.log

输出:

[2016-12-01 00:00:01] ...
[2016-12-01 00:00:02] ....

预期:

[2016-12-01 00:00:01] ...
[2016-12-01 00:00:02] ....
[2016-12-01 00:00:03] .....

为什么&#34;&lt; =&#34;不起作用吗?

1 个答案:

答案 0 :(得分:2)

因为$ 0是你的整个记录​​,而在第三行是“[2016-12-01 00:00:03] .....”,这超过“[2016-12-01 00: 00:03]”。