金曜日, 3月 25, 2011

ファイル内の文字列置換

カレントディレクトリ以下のファイル内のすべてのfooをbarに置換する。

$ find . -type f -print0 | xargs -0 perl -i.bak -pe 's/foo/bar/g'
$ find . -name "*.bak" -print0 | xargs -0 rm -f

も少しスマートにできんかね。