在固定搜索awk命令不能使用UNIX $变量 [英] can not use unix $variable in Fixed search of awk command
本文介绍了在固定搜索awk命令不能使用UNIX $变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能Fiexd搜索awk命令的使用UNIX $变量。
请参见下面的我的命令。
A =NEW_TABLES NEW_INSERT
B =NEW
回声$ A | AWK -v MYVAR = $ B -F'$ 0〜MYVAR''{$打印2}
没有返回任何输出
但如果手动输入$ B值出现,其工作如下
回声$ A | AWK -v -F'NEW''{打印$ 2}' 输出:
TABLES NEW_INSERT
解决方案
这应该使它:
$ a =NEW_TABLES NEW_INSERT$回声$ A | awk的-FNEW_'{打印$ 2}'
TABLES$ B =NEW_
$回声$ A | awk的-F$ B'{$打印2}
TABLES
I can not use unix $variable in Fiexd search of awk command.
Please see below my commands.
a="NEW_TABLES NEW_INSERT"
b="NEW"
echo $a | awk -v myvar=$b -F'$0~myvar' '{print $2}'
is not returning any output
but if manually enter the $b value there , its working as below
echo $a | awk -v -F'NEW' '{print $2}'
outputs:
TABLES NEW_INSERT
解决方案
This should make it:
$ a="NEW_TABLES NEW_INSERT"
$ echo $a | awk -F"NEW_" '{print $2}'
TABLES
$ b="NEW_"
$ echo $a | awk -F"$b" '{print $2}'
TABLES
这篇关于在固定搜索awk命令不能使用UNIX $变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文