-1

次のディレクトリ にいて、他の100個のファイルからファイルA/B/C/propをチェックアウトする必要がある e0とします。これら2つのファイルには、次のエントリがあります。e1

$DBConnection_target=targetname
$DBConnection_source1=sourcename

変更する必要があるのはtargetnamesourcenameキーボード (読み取り) から取得した、使用される文字列のみです。これらの文字列は、2 ~ 3 回以上発生する場合があります。

4

1 に答える 1

2

以下に示すように、とsedの 2 つのファイルで置換を実行するために使用できます。e0e1

# 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
于 2013-04-30T12:28:41.990 に答える