MOH*_*MED 19 linux bash shell awk
awk输出看起来像:
awk '{print $2}'
toto
titi
tata
Run Code Online (Sandbox Code Playgroud)
我想在同一行中以空格作为分隔符而不是新行来显示awk的输出
awk [option] '{print $2}'
toto titi tata
Run Code Online (Sandbox Code Playgroud)
有可能吗?
Man*_*y D 35
从联机帮助页:
ORS The output record separator, by default a newline.
Run Code Online (Sandbox Code Playgroud)
因此,
awk 'BEGIN { ORS=" " }; { print $2 }' file
Run Code Online (Sandbox Code Playgroud)
Jot*_*tne 17
您始终可以使用它 printf
来控制输出awk
awk '{printf "%s ",$2}' file
toto titi tata
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
30550 次 |
最近记录: |