LoginSignup
27
27

More than 5 years have passed since last update.

Ruby 2.0で必要なくなったmagic commentをまとめて消したい!

Last updated at Posted at 2013-06-27

Ruby 2.0からデフォルトのエンコーディングがUS-ASCIIからUTF-8に変わりました(参照: http://bugs.ruby-lang.org/issues/6679)

ということで、必要のなくなったmagic commentをディレクトリ下の.rbファイルから一括削除してみましょう。

$ find . -type f -name '*.rb' -print0 | xargs -0 sed -i '' '/^#.*coding.*[uU][tT][fF]\-8/d'

ついでにファイルの先頭にある空行もまとめて削除。

$ find . -type f -name '*.rb' -print0 | xargs -0 -n 1 sed -i '' '/./,$!d'

スッキリ!!

27
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
27