Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

For example:

sed 's/ones/one's/' <<< 'ones thing'
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...