macosでダウンロードしてきたスクリプトを実行した時に-Pオプションでエラーになりました。
grep: invalid option -- P
どうやらmacosのgrepは-Pオプションが無いようです.
$ grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
$ grep --help
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
解決方法
- brewにてgnu grepをインストールします。
$ brew install grep
...
$ ggrep --version
ggrep (GNU grep) 3.7
Packaged by Homebrew
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
- スクリプト中の
grep
をggrep
に置き換えます。
以上。