linux 中判断一组数据是否有交叉
001、shell实现
[root@pc1 test2]# ls a.txt [root@pc1 test2]# cat a.txt ## 测试数据 1 4 6 10 8 16 17 20 [root@pc1 test2]# cat a.txt | tr " " "\n" | sed -e '1d' -e '$d' | sed 'N; s/\n/ /' | awk '$2 <= $1 { print NR"-"NR + 1, $0}' 2-3 10 8

[root@pc1 test2]# ls a.txt [root@pc1 test2]# cat a.txt 1 4 6 10 8 16 17 20 23 30 32 39 40 45 43 50 [root@pc1 test2]# cat a.txt | tr " " "\n" | sed -e '1d' -e '$d' | sed 'N; s/\n/ /' | awk '$2 <= $1 { print NR"-"NR + 1, $0}' 2-3 10 8 7-8 45 43
002、python实现

浙公网安备 33010602011771号