AWK コマンドについて簡単な質問があります。同じ行の行末まで印刷するコマンドが必要ですが、次の行に到達したら別の行に印刷する必要があります。次の例は、より明確になります。
ファイルがあるとします:
0 1 2 3 This is line one
0 1 2 3 This is line two
0 1 2 3 This is line three
0 1 2 3 This is line four
私は次のことを試し、次の結果を得ました
awk '{for(i=5;i<=NF;i++) print $i}' fileName >> resultsExample1
resultsExample1 で次の結果が得られます
This
is
line
one
This
is
line
two
And so on....
例 2:
awk 'BEGIN {" "} {for(i=5;i<=NF;i++) printf $1}' fileName >> resultsExample2
resultsExample2 の場合:
This is line one This is line two this is line three This is line four
私も試しました:
awk 'BEGIN {" "} {for(i=5;i<=NF;i++) printf $1}' fileName >> resultsExample3
しかし、結果は前回と同じでした
最後に、私は次のことを望みます:
This is line one
This is line two
This is line three
This is line four
どんな助けにも感謝します!前もって感謝します :)