Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ヘッダーと結果の列がいくつかある要約ファイルを出力するプログラムがあります。ファイル名と最適な期間予測の 2 つのデータのみを表示したいので、次のコマンドを使用します。
program input_file | gawk 'NR==2 {print $3}; NR==4 {print $2}'
結果として、1列2行で結果が得られます。この結果を 1 行 2 列にするにはどうすればよいですか?
あなたが使用することができます:
program input_file | gawk 'NR==2 {heading = $3}; NR==4 {print heading " = " $2}'
$3これにより、 2 行目の値が variable に保存されheading、4 行目を読み取るときに見出しと列 2 の値が出力されます。
$3
heading