まとめてファイル置換する
hoge
ディレクトリの中にある.rb
ファイル中にある文字列foo
をbar
に置換する。-i "0" を指定することでバックアップファイルを作らないようになる。
$ find ./hoge -type f -name "*.rb" -print0 | xargs -0 sed -i "" -e "s/foo/bar/g"
Redis.new.flushall
を含む行全てを削除する。
$ find ./spec/ -type f -name "*.rb" -print0 | xargs -0 sed -i "" -e "/Redis.new.flushall/d"