如何逃避awk的单引号里面的printf [英] how to escape single quote in awk inside printf
本文介绍了如何逃避awk的单引号里面的printf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要做到以下
awk 'BEGIN {FS=" ";} {printf "'%s' ", $1}'
但逃逸单引号这样不起作用
But escaping single quote this way does not work
awk 'BEGIN {FS=" ";} {printf "\'%s\' ", $1}'
如何做到这一点?感谢您的帮助。
How to do this? Thanks for help.
推荐答案
这或许你要找的是什么:
This maybe what you're looking for:
awk 'BEGIN {FS=" ";} {printf "'\''%s'\'' ", $1}'
也就是说,'\\''
关闭打开的
,然后打印文字
通过转义它最后打开
。
That is, with '\''
you close the opening '
, then print a literal '
by escaping it and finally open the '
again.
这篇关于如何逃避awk的单引号里面的printf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文