8
7

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.

mac標準のgrepはなぜかエラーが出るので、brew install grepしてみた

Last updated at Posted at 2018-05-09

grepしたらエラーが出るので、解決策を記します。

#mac標準のgrepだとエラーがでる

mac標準のgrepを使ってみました。

$ grep -r "こんにちは"
egrep: warning: recursive search of stdin

なんなんやろ、このエラー
調べてもわかりませんでしたが、解決策はわかりました。

#解決策は「brew install grep」
Homebrewからgrepをインストールし、PATHを通したらいけます!

$ brew install grep

「.bashrc」を開いて下記を追加

PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
MANPATH="/usr/local/opt/grep/libexec/gnuman:$MANPATH"

「.bashrc」を読み込む

$ source ~/.bashrc

もう一回grepしてみる

$ grep -r "こんにちは"
hello/hello.html

いけました!

8
7
1

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
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?