我想用「的awk」來提取一個格式化的文件的具體信息,以便:AWK打印列,如果條件得到滿足
- 如果行有2場,第一列(100)被打印,並且第二列(2)表示跟隨的「X」對線對如果對應於NR +(2 * X -1)的行以「B」開始,則該行的第二列打印
- 如果NR +(2 * X -1)的相應行未以「B」開頭,則打印值爲「0」。
示例文件:
100 2
A .5 .4
.3 .2 .1
B .9 .8
.7 .6 .65
200 1
A .5 .4
.3 .2 .1
理想輸出:
100 .9
200 0
代碼迄今:
awk '{if(NF==2) print $1;}'
主要生產:
100
200
你應該表現出你已經嘗試過。 –
我不是awk專家,但請在您的帖子中包含該信息。它會幫助有人決定如何幫助你。 –