Detect OS from Bash script and notify user
Rather than single quotes, you probably meant to use backticks:
OS=`uname -s`
but you really want
OS=$(uname -s)
Also, rather than an if statment, which will eventually become an if/else series, you might consider using case:
case $( uname -s ) inLinux) echo Linux;;*) echo other;;esac
This will return the OS as requested - note that uname
is not necessarily available on all OSes so it's not part of this answer.
case "$OSTYPE" in linux*) echo "linux" ;; darwin*) echo "mac" ;; msys*) echo "windows" ;; solaris*) echo "solaris" ;; bsd*) echo "bsd" ;; *) echo "unknown" ;;esac