带有特殊字符的 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屋!
查看全文