Skip to content

Instantly share code, notes, and snippets.

@bermi
Created November 21, 2012 16:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bermi/4125858 to your computer and use it in GitHub Desktop.
Save bermi/4125858 to your computer and use it in GitHub Desktop.
Bash simple operating system detection
#!/bin/bash
os=${OSTYPE//[0-9.-]*/}
case "$os" in
darwin)
echo "I'm a Mac"
;;
msys)
echo "I'm Windows using git bash"
;;
linux)
echo "I'm Linux"
;;
*)
echo "Unknown Operating system $OSTYPE"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment