001、
[root@pc1 test2]# ls index.txt [root@pc1 test2]# cat index.txt ## 测试的一列数字 2 3 4 8 9 11 [root@pc1 test2]# awk '{if(NR == 1) {a = $0 - 0 - 1; for (i = 1; i <= a; i++) {print "0"};print $0; tmp = $0} else if ($0 - tmp != 1){a = $0 - tmp - 1; for (i = 1; i <= a; i++) {print "0"}; print $0; tmp = $0 } else {print $0; tmp = $0}}' index.txt 0 ## 将非连续的数字间隔全部补充为0 2 3 4 0 0 0 8 9 0 11
。
标签:字符,test2,pc1,一列,linux,txt,root From: https://www.cnblogs.com/liujiaxin2018/p/17758495.html