LoginSignup
2
1

More than 5 years have passed since last update.

Macでディレクトリを再帰的にファイル内の文字列を一括置換する

Posted at

findで再帰的にファイルを検索してgrep -vでログファイルなどの不要なファイルを除外してsedで置換。
Macのsedのiオプションがlinuxと挙動が違うので-iだけではなく-i ''とする。

find . -type f | grep -v '\.log$' | xargs sed -i '' 's/hoge/fuga/g'
2
1
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
2
1