I need to replace a fairly varied string that looks like such (Mac OS):
我需要替换一个看起来像这样的相当多的字符串(Mac OS):
DBVARNAME="<anything>"
or
要么
dbvarname="<anything>"
or any other combination of case.
或任何其他案件组合。
I need to find all occurrences of this in every file and replace it with " " (one blank space).
我需要在每个文件中找到所有这些,并用“”(一个空格)替换它。
An entire line would be similar to this:
整行与此类似:
<cfprocparam type="Out" dbvarname="locked" cfsqltype="CF_SQL_CHAR" variable="locked" value="#locked#">
I have tried:
我努力了:
grep -irl dbvarname web|xargs sed -i '' 's/dbvarname=".*" / /g'
I realize that this is case sensitive which is one issue. The other is that there are some occurrences where there is a trailing comma after the pattern and I do NOT want to remove those occurrences.
我意识到这是区分大小写的,这是一个问题。另一种情况是,在模式之后有一些尾随逗号,并且我不想删除这些事件。
Any help is appreciated, thank you.
感谢任何帮助,谢谢。
1 个解决方案
#1
1
or any other combination of case.
或任何其他案件组合。
[dD][bB][vV][aA][rR][nN][aA][mM][eE]
The other is that there are some occurrences where there is a trailing comma after the pattern and I do NOT want to remove those occurrences.
另一种情况是,在模式之后有一些尾随逗号,并且我不想删除这些事件。
...\([^,]\)/\1/g
so, put them together:
所以,把它们放在一起:
sed 's/[dD][bB][vV][aA][rR][nN][aA][mM][eE]="[^"]*"\([^,]\)/\1/g'
#1
1
or any other combination of case.
或任何其他案件组合。
[dD][bB][vV][aA][rR][nN][aA][mM][eE]
The other is that there are some occurrences where there is a trailing comma after the pattern and I do NOT want to remove those occurrences.
另一种情况是,在模式之后有一些尾随逗号,并且我不想删除这些事件。
...\([^,]\)/\1/g
so, put them together:
所以,把它们放在一起:
sed 's/[dD][bB][vV][aA][rR][nN][aA][mM][eE]="[^"]*"\([^,]\)/\1/g'