70
Help us understand the problem. What are the problem?

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

以上

  • 自分メモ
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
70
Help us understand the problem. What are the problem?