Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我在以下目录中 A/B/C/prop,需要检查 其他 100 个文件中的文件。在这两个文件中,我有以下条目e0:e1
A/B/C/prop
e0
e1
$DBConnection_target=targetname $DBConnection_source1=sourcename
我只需要更改将要使用targetname的sourcename字符串,取自键盘(读取)。这些字符串可能出现超过 2-3 次。
targetname
sourcename
您可以使用sed和 来执行两个文件中的替换e0,e1如下所示:
sed
# set what you want the source and target to be changed to here: newSource=foo newTarget=bar sed -i 's/\($DBConnection_target\)=.*$/\1='"$newTarget"'/;s/\($DBConnection_source1\)=.*$/\1='"$newSource"'/' e0 e1