如何在sed中转义单引号? [英] How to escape single quote in sed?

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

问题描述

如何在已经被引号包围的 sed 表达式中转义单引号?

How to escape a single quote in a sed expression that is already surrounded by quotes?

例如:

sed 's/ones/one's/' <<< 'ones thing'

推荐答案

用双引号引用 sed 代码:

Quote sed codes with double quotes:

    $ sed "s/ones/one's/"<<<"ones thing"   
    one's thing

我不喜欢用数百个反斜杠转义代码 - 伤我的眼睛.通常我是这样做的:

I don't like escaping codes with hundreds of backslashes – hurts my eyes. Usually I do in this way:

    $ sed 's/ones/onex27s/'<<<"ones thing"
    one's thing

这篇关于如何在sed中转义单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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