linux 中 awk直接引入外部变量

 

001、

[root@pc1 test1]# ls
a.txt
[root@pc1 test1]# a=4             ## 定义变量a
[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

 。

 

posted @ 2023-10-12 10:15  小鲨鱼2018  阅读(108)  评论(0编辑  收藏  举报