「Shell」unameコマンドでOSを確認する方法
1.環境変数の確認(例CentOS)
# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
# echo $(uname)
Linux
2.OSを判別
if [ "$(uname)" == 'Darwin' ]; then echo 'Mac' elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then echo 'Linux' else echo "os is not support." exit 1 fi