AWK传参

"''$var'"
var="test"
awk 'BEGIN{print "'$var'"}'
'"$var"'
var="this is a test"
awk 'BEGIN{print "'"$var"'"}'
export变量,使用ENVIRON["var"]形式,获取环境变量的值
var="this is a test"; export var;
awk 'BEGIN{print ENVIRON["var"]}'
awk的-v选项
var="this is a test"
awk -v awk_var="$var" 'BEGIN {print awk_var}'

你可能感兴趣的:(AWK传参)