Linux 是否可以在同一行中打印awk输出
awk输出如下所示:Linux 是否可以在同一行中打印awk输出,linux,bash,shell,awk,Linux,Bash,Shell,Awk,awk输出如下所示: awk '{print $2}' toto titi tata 我想用空格作为分隔符,而不是新行,在同一行中显示awk的输出 awk [option] '{print $2}' toto titi tata 可以这样做吗?从手册页: ORS The output record separator, by default a newline. 所以, awk 'BEGIN { ORS=" " }; { print $2 }' file 或者您可以使用粘
awk '{print $2}'
toto
titi
tata
我想用空格作为分隔符,而不是新行,在同一行中显示awk的输出
awk [option] '{print $2}'
toto titi tata
可以这样做吗?从手册页:
ORS The output record separator, by default a newline.
所以,
awk 'BEGIN { ORS=" " }; { print $2 }' file
或者您可以使用
粘贴
awk '{print $2}' FILE |paste -sd " "
您始终可以使用printf
控制awk
awk '{printf "%s ",$2}' file
toto titi tata
我会像这样写awk'{print$2}'ORS=”“file
,但这是您喜欢的更多选择。