シェルスクリプトでディレクトリ以下のファイル中の文字列を一括置換
FreeBSD 4.11 用に mplayer のソースコードの中の stdint.h を inttypes.h に書き換えたかった。
[O] sedとgrepで、あるディレクトリ以下のファイル中の文字列を一括置換
grep -lr stdint.h * | grep -v '.svn/'| grep -v 'configure.log'| xargs sed -i 's/'stdint.h'/'inttypes.h'/g'
ありゃエラーが
sed: 1: “dvdread/nav_print.c”: extra characters at the end of d command
ではこれを参考に
grep -lr stdint.h * | grep -v '.svn/'| grep -v 'configure.log'| xargs perl -pi -e 's/stdint\.h/inttypes\.h/g'
こんなのもあり