gpt4 book ai didi

linux - 是否可以在同一行中打印 awk 输出

转载 作者:IT王子 更新时间:2023-10-29 00:20:04 26 4
gpt4 key购买 nike

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

关于linux - 是否可以在同一行中打印 awk 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24331687/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com