第一列顺序不变对第二列进行排序
source data:
Ph_scaffold57_2 6002125 Ph_scaffold57_2 1826520 Ph_scaffold4 54818110 Ph_scaffold4 53507591 Ph_scaffold4 51550443 Ph_scaffold4 15513112 Ph_scaffold243 767655
script:
#!/bin/awk -f # # usage: ./script source_data <(echo) # <(echo) 使用子shell添加一空行,对最后一行进行模式匹配 NR>1 && i!=$1 { for(j=0;j++<asorti(a,b);) print i,b[j] delete a } { i=$1 a[$2] }
result:
Ph_scaffold57_2 6002125 Ph_scaffold57_2 1826520 Ph_scaffold4 54818110 Ph_scaffold4 53507591 Ph_scaffold4 51550443 Ph_scaffold4 15513112 Ph_scaffold243 767655
*** 你必须十分努力,才能看起来毫不费力 ***