linux 中判断一列数据是否按照指定步长递增

 

linux 中判断一列数据是否按照指定步长递增

 

001、

[root@pc1 test01]# ls
a.txt  b.txt
[root@pc1 test01]# cat a.txt              ## 测试数据, 正确递增
1
2
3
4
5
6
[root@pc1 test01]# cat b.txt              ## 测试数据, 异常递增
1
2
4
5
6
[root@pc1 test01]# awk '{if(NR == 1) {tmp = $1} else {if($1 - tmp != 1) {print NR, "error"}; tmp=$1}}' a.txt
[root@pc1 test01]# awk '{if(NR == 1) {tmp = $1} else {if($1 - tmp != 1) {print NR, "error"}; tmp=$1}}' b.txt
3 error

 。

 

posted @ 2024-05-04 09:56  小鲨鱼2018  阅读(10)  评论(0编辑  收藏  举报