15
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOS標準sedをGNU sedに置き換える

Posted at

macOS標準添付 sed コマンドはGNU拡張非対応のため、下記のようなワンライナーが期待通り動作しない。

$ find . -name "pattern" | xargs sed -i "s/old/new/g"

Homebrew経由でインストールされるGNU sed (gsed)を導入し、標準 sed コマンドより探索優先度を上げる。(オリジナルを呼び出す場合は/usr/bin/sed

$ brew install gnu-sed
$ echo 'export PATH="/usr/local/opt/gnu-sed/libexec/gnubin/:$PATH"' >> ~/.bashrc

2019年1月現在、一部記事で紹介されているbrew install時の--with-default-namesオプションは機能しない模様。

動作環境

  • macOS 10.14.3
  • GNU sed 4.7
15
8
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
15
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?