LoginSignup
31
31

More than 5 years have passed since last update.

sedで一括置換

Last updated at Posted at 2013-02-22

Gitで管理しているファイルの中でこの文字列を全部ガガガっと書き換えたいという時に使うと便利なコマンド。

$ git grep -l | xargs sed -i "" "s/h/m/g"

仕組みは↓こんな感じ。

  • git grep で置換したいファイルを探し出す
  • ファイル名だけをstdoutに吐き出す
  • xargsでsedに渡す

ex) hogeをfugaに置き換えたい。全ファイルで。

$ git grep -l "hoge" | xargs sed -i "" "s/hoge/fuga/g"
31
31
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
31
31