linux 中 awk直接引入外部变量

发布时间 2023-10-12 10:20:37作者: 小鲨鱼2018

 

001、

[root@pc1 test1]# ls
a.txt
[root@pc1 test1]# a=4
[root@pc1 test1]# cat a.txt
1
[root@pc1 test1]# awk '{for(i = 1; i <= "'$a'"; i++) print "xx"}' a.txt
xx
xx
xx
xx

 。