書式の変更と数の並べ替え

書式の変更と数の並べ替え

形式を変更したいです。

送信者: サンプル.txt

   Count   Data
   1 C0263/Pre-approved Auto Load BC
   1 C0263/Pre-approved Auto Load BC Holders
   3 C0268/Pre-approved Auto Loan

受信者:output.txt

   Data                                       Count
   C0263/Pre-approved Auto Load BC            1
   C0263/Pre-approved Auto BC Holders         1
   C0268/Pre-approved Auto Loan               3

ベストアンサー1

アッ解決策:

awk 'NR==1{ printf "%4s%-44s%s\n",FS,$2,$1; next }
     { f1=$1; sub(/^ *[^ ]+ */,""); printf "%4s%-44s%s\n",FS,$0,f1 }' Sample.txt

出力:

    Data                                        Count
    C0263/Pre-approved Auto Load BC             1
    C0263/Pre-approved Auto Load BC Holders     1
    C0268/Pre-approved Auto Loan                3

おすすめ記事