001、
[root@PC1 test]# ls a.txt b.txt [root@PC1 test]# cat a.txt ## 测试数据a.txt gene exon gene exon exon exon exon [root@PC1 test]# awk 'BEGIN{idx=0} {if($0 == "gene") {idx++} else {idx = 0}; if(idx > 1) {print NR, "duplication"; exit}}' a.txt [root@PC1 test]# cat b.txt ## 测试数据b.txt gene exon gene exon gene gene exon [root@PC1 test]# awk 'BEGIN{idx=0} {if($0 == "gene") {idx++} else {idx = 0}; if(idx > 1) {print NR, "duplication"; exit}}' b.txt 6 duplication
标签:字符,gene,idx,PC1,exon,一列,linux,test,txt From: https://www.cnblogs.com/liujiaxin2018/p/17173949.html