awk的正则表达式匹配中,如果要使用外部shell
变量,先在变量外加双引号,再加单引号即可,如:
for i in read write print;
do
cat file.txt | awk '{ if ($7~/'"$i"'/) {print $0} }'| wc -l ;
done
for i in read write print;
do
cat file.txt | awk '{ if ($7~/'"$i"'/) {print $0} }'| wc -l ;
done