rpl 文字列置換ユーティリティ

ファイル中の文字列を置換するユーティリティ。
http://www.laffeycomputer.com/rpl.html

  • Ubuntu なら apt-get でインストールできるので手軽
  • -a をつけない限りドットで始まるファイル・ディレクトリは無視されるから .svn があっても平気
  • メッセージがけっこうわかりやすい
  • バックアップをとれる
  • 正規表現は使えない

これで日本語自動判別と正規表現に対応してれば完璧かも。

# 再帰的に。大文字・小文字を区別しない
[~/dl/rpl-1.4.1:0]$ rpl -Ri foo bar .
Replacing "foo" with "bar" (ignoring case) (partial words matched)
.....................................
A Total of 6 matches replaced in 37 files searched.

# シミュレーションモード(実際には置換しない)
[~/dl/rpl-1.4.1/src:0]$ rpl -s include hoge *.c
Simulating replacement of "include" with "hoge" (case sensitive) (partial words matched)
The files listed below would be modified in a replace operation.
  /home/ao/dl/rpl-1.4.1/src/estrcpy.c
  /home/ao/dl/rpl-1.4.1/src/replace.c
  /home/ao/dl/rpl-1.4.1/src/suffix.c
  /home/ao/dl/rpl-1.4.1/src/usage.c

A Total of 35 matches found in 4 files searched.
None replaced (simulation mode).

# 拡張子 txt だけ
[~/dl/rpl-1.4.1/test:0]$ rpl -sR -xtxt Bad Good  .
Simulating replacement of "Bad" with "Good" (case sensitive) (partial words matched)
The files listed below would be modified in a replace operation.
Skipping: ./sub/a.log (suffix not in list)
  /home/ao/dl/rpl-1.4.1/test/a.txt

A Total of 1 matches found in 1 file searched.
None replaced (simulation mode).