LoginSignup
72

More than 1 year has passed since last update.

posted at

updated at

シェルスクリプトでOSを判別する

  • シェルスクリプト実行時に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エディタの起動スクリプトを読んでいて気がつきました。

以上

  • 自分メモ

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
What you can do with signing up
72