Linux awk命令中如何刪除陣列

小鲨鱼2018發表於2024-07-10

001、Linux awk中如何刪除陣列

(base) [b20223040323@admin2 test]$ cut -f 5-6 rt288_2_3.bim  |  paste - <(cut -f 5-6 yt4_2_3.bim ) | head
C       A       0       A
T       C       C       T
C       A       C       A
A       C       C       A
T       G       T       G
T       C       0       C
A       C       A       C
G       A       0       A
C       A       A       C
A       G       0       G                                                                                                           ## 宣告陣列                          ## 刪除陣列        
(base) [b20223040323@admin2 test]$ cut -f 5-6 rt288_2_3.bim  |  paste - <(cut -f 5-6 yt4_2_3.bim ) | awk '{for(i = 1; i <= NF; i++){ay[$i];if(i == NF) {print length(ay); delete ay}}}' | head
3
2
2
2
2
3
2
3
2
3

相關文章