删除具有连续对的线 [英] Removing lines with consecutive pairs
本文介绍了删除具有连续对的线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有许多数字组合的文本文件.看起来像这样:
I have a text file with a lot of number combinations. It looks like this:
1 2 3 4 5 6
1 2 3 4 5 7
1 2 3 4 5 8
1 2 3 4 5 9
1 2 3 4 5 10
每行有6个数字,每个数字之间有一个空格.数字从1到37.
Every line has 6 numbers with a space between each number. Numbers go from 1 to 37.
我需要AWK命令才能删除具有2或3个连续对的任何行.
I need an AWK command to remove any line with 2 or 3 consecutive pairs.
例如:
1 2 6 9 13 14
4 5 18 19 25 26
谢谢!
推荐答案
awk '{pairs = 0; for (i = 1; i < NF; i++) if ($i + 1 == $(i + 1)) pairs++; if (pairs != 2 && pairs != 3) print}' input_file
这篇关于删除具有连续对的线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文