4
4

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 1 year has passed since last update.

シェルでコマンドがBSD版かGNU版かを見分けるお手軽な方法

Last updated at Posted at 2018-08-22

man を grep する手があるんじゃないだろうか。

BSD

Macでのコマンド類はデフォルトで BSD版なので、その例。

man man sed | grep -e BSD -e GNU | head -n 1
SED(1)                    BSD General Commands Manual                   SED(1)

GNU

Macでは GNU版のコマンドを brew で入れられる。その例。

man man gsed | grep -e BSD -e GNU | head -n 1
              disable all GNU extensions.

他のコマンドで試した例

bash-4.4$ man sed | grep -e BSD -e GNU | head -n 1
SED(1)                    BSD General Commands Manual
bash-4.4$ man gsed | grep -e BSD -e GNU | head -n 1
              disable all GNU extensions.
bash-4.4$ man cut | grep -e BSD -e GNU | head -n 1
CUT(1)                    BSD General Commands Manual
bash-4.4$ man gcut | grep -e BSD -e GNU | head -n 1
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
bash-4.4$ man stat | grep -e BSD -e GNU | head -n 1
STAT(1)                   BSD General Commands Manual                  STAT(1)
bash-4.4$ man gstat | grep -e BSD -e GNU | head -n 1
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>

Versions

  • Mac OS X High sierra

Links

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?