我的文件有数千行,看起来像
R4604 17131G1 499456.1 1966201.0 0.0 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4496 12011G1 473856.2 1960800.9 0.0 1000001
R4496 12011G1 473856.2 1960800.9 64.0 1000001
我希望得到的是输出
R4604 17131G1 499456.1 1966201.0 8.5 1000001
R4496 12011G1 473856.2 1960800.9 64.0 1000001
因此,如果第1-5列相同,则只获取一行,如果第1-4列相同且第5列中的值不同,则删除第5列值为0.0的行
感谢您的帮助 亚历杭德罗
答案 0 :(得分:3)
假设一个排序值,并且第5列总是0或组中每一行的非零值,并且第5列中没有要保留的行等于5:
awk '$5 != 0 {key = $1 $2 $3 $4 $5; if (prev != key) {print saved}; prev = key; saved = $0} END {print saved}' inputfile