【shell脚本实战案例】awk输出换行or不换行

问题背景:

awk 提取完数据追加输出的时候如何让数据不换行?

解决方法:

print 换行 / printf 不换行

#print 换行
cat file | awk '{print $0}' >> test.txt
#printf 不换行
cat file | awk '{printf $0}' >> test.txt

其中awk '{print $0}'中的$0表示整行文本,类似的还有:

$0 表示整行文本
$1 表示文本行中第一个数据字段
$n 表示文本行中第n个数据字段

猜你喜欢

转载自blog.csdn.net/qq_35902025/article/details/135016721