置換まとめ
perl -p -i.bak -e 's/foo/bar/g' *.hoge
非道版
perl -p -e 's/foo/bar/g' *.hoge
with grep
カレントディレクリ以下の'hoge'という文字列を含むファイルを検索し
そのファイル内の'foo'を、すべて'bar'に変換する。
grep -lr 'hoge' . | xargs perl -p -i.bak -e 's/foo/moge/g' *.hage
with find
カレントディレクリ以下の'hoge'という文字列を含むファイル名のファイルを検索し
そのファイル内の'foo'を、すべて'bar'に変換する。
find . -name '*.hoge' -type f -print | xargs perl -p -i.bak -e 's/foo/bar/g'
.bakファイルの削除
find . -name '*.bak' -exec rm -f {} ?;