我有text1.txt,它包含
<this can be anything, any number of line - no hardcoded>
<this can be anything, any number of line - no hardcoded>
param1=<this can be any value - no hardcoded>
<this can be anything, any number of line - no hardcoded>
<this can be anything, any number of line - no hardcoded>我想用替换这个部分,它可以是任何值-没有硬编码的,用abc
什么是正确的SED命令?请注意,由于环境限制,我没有使用任何语言(如perl、python或ruby ~)的灵活性,只能使用Unix命令。除了param1之外,没有硬编码。
提前谢谢!
发布于 2012-04-10 08:28:50
你想要的调用是
sed -e 's/param1=.*/param1=abc/' text1.txt发布于 2012-04-10 09:07:12
听起来你想要像s/<.\+>$/<abc>/一样的东西
$ cat test1.txt
<this can be anything, any number of line - no hardcoded>
<this can be anything, any number of line - no hardcoded>
param1=<this can be any value - no hardcoded>
<this can be anything, any number of line - no hardcoded>
<this can be anything, any number of line - no hardcoded>
$ sed 's/<.\+>$/<abc>/' test1.txt
<abc>
<abc>
param1=<abc>
<abc>
<abc>https://stackoverflow.com/questions/10085360
复制相似问题