1

すべての行が同じファイルがありますが、最初の行には、他のすべてのフィールドに使用したい定数のセットがあります。

File.txt (タブ区切り)

ABC 1 2 3 4

防御力

GHI

私は結果がその線に沿っていることを望みます

ExpectedOutcome.txt

1 2A B 3 C 4

1 2D E 3 F 4

1 2G H 3 I 4

私が持っている現在のコードは、最初の行のみを正しく処理してから終了します

ActualOutcome.txt

1 2A B 3 C 4

コード

#!/bin/sh
Begin{FS="\t";OFS="\t"}
{
      if(NR=1){
           FirstConstant=$4;
           SecondConstant=$5;
           ThirdConstant=$6;
           FourthConstant=$7;
       }
       if($1){
            Combo=SecondConstant $1;
        }
        print FirstConstant, Combo, $2, ThirdConstant, $3, FourthConstant;
  }
4

1 に答える 1