awk 引用shell变量的几种方法
一、-v选项
[root@159 shell]# a=test
[root@159 shell]# awk -v b="$a" 'BEGIN{print b}'
test
[root@159 shell]# awk -v b="$a" 'BEGIN{print b}'
test
二、双引号中加单引号
[root@159 shell]# awk 'BEGIN{print "'$a'"}'
test
test
三、单引号中加双引号
[root@159 shell]# awk 'BEGIN{print '\"$a\"'}'
test
test
转载于:https://blog.51cto.com/huoxiubo/714267