sed有特殊字符 [英] sed with special characters
本文介绍了sed有特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这行要在sed上使用:
I have this line that I want to use sed on:
--> ASD = $start ( *.cpp ) <--
$ start不是变量,我想在上面使用sed并将所有这行替换为:
where $start is not a varaiable, I want to use sed on it and replace all this line with:
ASD = $dsadad ( .cpp )
我如何让sed忽略特殊字符,我曾尝试在特殊字符前加反斜杠,但也许我弄错了,有人可以举个例子吗?
How can I make sed ignore special charactars, I tried adding back slash before special characters, but maybe I got it wrong, can some one show me an example?
这就是我想要的:
sed 's/CPPS = \$(shell ls | grep \*\.cpp )/somereplace/' Makefile
推荐答案
sed 's/\$start/\$dsadad/g' your_file
>> ASD = $dsadad ( *.cpp )
sed 's/\*//g' your_file
>> ASD = $start ( .cpp )
要遵循您的修改:
sed -i 's/ASD = \$start ( \*.cpp )/ASD = \$dsadad ( .cpp )/' somefile
>> ASD = $dsadad ( .cpp )
添加-i(--inplace)以编辑输入文件.
Add the -i (--inplace) to edit the input file.
这篇关于sed有特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文