LoginSignup
7
3

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"
7
3
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
7
3