0

特定の「sed」コマンドを推奨する次の他のスレッドを見てきました。

https://superuser.com/questions/428493/how-can-i-do-a-recursive-find-and-replace-from-the-command-line

検索/sed:ファイル内の文字列を再帰的に検索/置換する方法はありますが、特定の正規表現に一致する行のみを対象としています

Mac および Linux でのテキスト ファイルでの再帰的な検索と置換

perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt

find . -type f -name '*.txt' -exec sed -i '' s/this/that/ {} +

ディレクトリ内の複数のファイルで発生する以下のサンプルを置き換えようとしています。

<script src="http://localhost/massignition/wp-content/themes/twentythirteen/js/html5.js"></script>

次のように (localhost/massignition を www.site.com に置き換えます)

次のように入力します。

find . -type f -name '*.txt' -exec sed -i '' s%localhost/massignition%www.site.com%/ {} +

しかし、何も変わりません。

4

1 に答える 1

1

コマンドの中括弧の前にある / を削除します。つまり、

探す 。-type f -name '*.txt' -exec sed -i '' s%localhost/massignition%www.site.com% {} +

それ以外の

探す 。-type f -name '*.txt' -exec sed -i '' s%localhost/massignition%www.site.com%/ {} +

于 2013-09-19T06:14:56.270 に答える