LoginSignup
97
72

bashでOSを判別する

Last updated at Posted at 2014-09-02
  • シェルスクリプト実行時にMacOSX,Linux,Cygwinのいずれかを判別する
if [ "$(uname)" == 'Darwin' ]; then
  OS='Mac'
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
  OS='Linux'
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then                                                                                           
  OS='Cygwin'
else
  echo "Your platform ($(uname -a)) is not supported."
  exit 1
fi
echo $(uname)

情報源

  • /usr/local/bin/atom
  • Macにインストールしたatomエディタの起動スクリプトを読んでいて気がつきました。

以上

  • 自分メモ
97
72
2

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
97
72