linux 中 awk printf如何同时输出字符串和数值

 

001、

[root@PC1 test1]# ls
a.txt
[root@PC1 test1]# cat a.txt                ## 测试文本
aa bb ee
33 ff rr
aa ff yy
[root@PC1 test1]# awk 'NR == 2 {printf("%s\t%d\n", $2, 100)}' a.txt      ## 前者输出字符串;后者输出数值
ff      100

 。

 

posted @ 2024-02-15 17:50  小鲨鱼2018  阅读(25)  评论(0编辑  收藏  举报