我如何逃脱SED双人和单引号? (庆典) [英] How do I escape double and single quotes in SED? (bash)
问题描述
这是我能找到,当您使用单引号里面的东西被认为是文字。我想,对于我的替换。但我也想找到一个具有单或双引号的字符串。
From what I can find, when you use single quotes everything inside is considered literal. I want that for my substitution. But I also want to find a string that has single or double quotes.
例如,
sed -i 's/"http://www.fubar.com"/URL_FUBAR/g'
我想URL_FUBAR取代http://www.fubar.com。战略经济对话应该如何识别我//或我的双引号?
I want to replace "http://www.fubar.com" with URL_FUBAR. How is sed supposed to recognize my // or my double quotes?
感谢您的帮助!
编辑:我能使用 S / \\HTTP \\:\\ / \\ / WWW \\ .fubar \\ \\ COM \\/ URL_FUBAR / G
?
请问\\其实单引号内逃脱字符?
Does \ actually escape chars inside the single quotes?
推荐答案
的 SED
命令可以为其他字符,而不是 /
:
The sed
command allows you to other characters instead of /
:
sed 's#"http://www.fubar.com"#URL_FUBAR#g'
双引号是没有问题的。
The double quotes are not a problem.
这篇关于我如何逃脱SED双人和单引号? (庆典)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!