如何使用Perl解释器对单引号进行转义? [英] How do I escape single quotes with perl interpreter?

查看:51
本文介绍了如何使用Perl解释器对单引号进行转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在bash表达式 find中转义单个qoutes.|xargs perl -pi -e's/'conflicts'=>",//g'?我要在文件中替换字符串'conflicts'=>''吗?

How do I escape the single qoutes in my bash expression find . | xargs perl -pi -e 's/'conflicts' => '',//g'? I want to replace the string 'conflicts' => '', in my files?

推荐答案

您不能在单引号中直接将其转义,因此要获得单引号,您需要执行以下操作:

You can't directly escape it within single quotes, so to get a single quote you need to do something like:

$ echo 'i'\''m a string with a single quote'
i'm a string with a single quote

这结束了被引号的部分,转义了单引号,就像它在引号外一样,然后再次开始了引号.结果仍然是一个参数.

This ends the quoted part, escapes a single quote as it would appear outside of quotes, and then begins the quoting again. The result will still be one argument.

这篇关于如何使用Perl解释器对单引号进行转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆