I have a list of files with strings like {{abc-exfs-value}}
. The sub string abc differs in each of the file. For example, a regex search (java) like: \{\{*-exfs-value\}\}
will return all the strings that is of concern here. How to proceed on replacing all those strings that match the regex pattern in files in linux?
我有一个包含{{abc-exfs-value}}等字符串的文件列表。子串abc在每个文件中都不同。例如,正则表达式搜索(java)如:\ {\ {* - exfs-value \} \}将返回此处关注的所有字符串。如何在linux中的文件中替换所有匹配正则表达式模式的字符串?
I am able to get the list of files using grep -R '\-exfs\-value' .
. Using sed how to replace the strings?
我能够使用grep -R'\ -exfs \ -value'获取文件列表。使用sed如何替换字符串?
1 个解决方案
#1
1
I would think this is what's needed:
我认为这就是我们所需要的:
sed -i.bak 's/\({{\)[[:alnum:]]\+\(-exfs-value}}\)/\1xyz\2/g' file1 file2 ...
#1
1
I would think this is what's needed:
我认为这就是我们所需要的:
sed -i.bak 's/\({{\)[[:alnum:]]\+\(-exfs-value}}\)/\1xyz\2/g' file1 file2 ...