More than 5 years have passed since last update.

find, xargs, sed(gsed) でファイルの一部を置換して保存する

Last updated at Posted at 2017-04-09

1024 番煎じくらいですが毎度忘れるので。

# sed -i は上書き更新オプション
find ./path/do/dir -name '*.js' | xargs sed -i "s/foo/bar/g"

# Mac だと sed -i が使えないので、事前に brew install gnu-sed などして gsed を使えるようにする
find ./path/do/dir -name '*.js' | xargs gsed -i "s/foo/bar/g"

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
What you can do with signing up