awk 特定の行の特定の列を置き換える

awk 特定の行の特定の列を置き換える

私のデータファイルは

sdfsdfsdf
1 0.5000 0.5000 0.5000 8 7 90 135  90 135 1 
2 0.5000 0.5000 0.0000 8 7 90 -45  90 -45 1 
3 0.0000 0.5000 0.5000 8 7 90 225  90 225 1 
4 0.5000 0.0000 0.5000 8 7 90 45   90 45  1 
sdfsdfsdf
sdfsdfsdfsdfsdfsdfsdf

7列と9行2~5行を変更して結果は次のようになります。

sdfsdfsdf
1 0.5000 0.5000 0.5000 8 7 60 135  60 135 1 
2 0.5000 0.5000 0.0000 8 7 60 -45  60 -45 1 
3 0.0000 0.5000 0.5000 8 7 60 225  60 225 1 
4 0.5000 0.0000 0.5000 8 7 60 45   60 45  1 
sdfsdfsdf
sdfsdfsdfsdfsdfsdfsdf

sedまたはawkを使用してこれをどのように実行できますか?頑張った

awk 'NR>=2&&NR<=5{$7="60"}' input.dat > tmp && mv tmp input.dat

しかし、これはうまくいきません

ベストアンサー1

努力する:

awk 'FNR==2,FNR==5{$7=$9=60};1' input.dat > tmp

おすすめ記事