在AWK中输出特殊字符-单引号

来源:互联网 发布:club域名续费多少钱 编辑:程序博客网 时间:2024/05/22 02:21

在AWK中输出单引号实现方式比较特殊:

> unameLinux

对于输出字符串使用到单引号:

单引号双引号单引号转义单引号单引号-字符串-单引号转义单引号单引号双引号单引号(下划线部分为输出单引号,相同颜色符号对应)

> echo aaa | awk '{print "select * from A where name='\''TOM'\''"}'select * from A where name='TOM'

对于输出域变量使用到单引号:

单引号双引号单引号转义单引号单引号双引号-域变量-双引号单引号转义单引号单引号双引号单引号(下划线部分为输出单引号,相同颜色符号对应)

> echo TOM | awk '{print "select * from A where name='\''"$1"'\''"}'select * from A where name='TOM'

对于输出环境变量使用到单引号:

单引号双引号单引号转义单引号单引号单引号-环境变量-单引号单引号转义单引号单引号双引号单引号(下划线部分为输出单引号,相同颜色符号对应)

> key=TOM; echo aaa | awk '{print "select * from A where name='$key'"}'select * from A where name=TOM> key=TOM; echo aaa | awk '{print "select * from A where name='\'''$key''\''"}'select * from A where name='TOM'

其它特殊字符:

$`(美元符、反引号)只需在双引号内即可,\(反斜杠)需要在前面加上反斜杠

echo aaa | awk '{print "$\\`"}'$\`




原创粉丝点击