How to escape the ampersand character while using sed

前端 未结 3 1480
囚心锁ツ
囚心锁ツ 2020-12-30 07:25

I want to replace all single quotes in a string with two single quotes using sed. But when the string contains the & character, the sed command is not repla

3条回答
  •  难免孤独
    2020-12-30 07:55

    It's working for me

    bash>echo "'This is a string with 'single quote' & '&'" | sed "s/'/''/g"
    ''This is a string with ''single quote'' & ''&''
    

提交回复
热议问题