Operating System Checks in Bash

I have been using my Mac and Linux computers a lot more recently. Syncing configurations between the two machines is pretty easy with tools like JungleDisk or Dropbox. Today I just started syncing my .bashrc and .bash_profile between the two systems. There are some configurations that need to be different on a per machine basis however. I wrote this quick little bash script to illustrate an easy way to do this. Pretty trivial but useful nonetheless.


if [ "$OS" = "Darwin" ]; then
  echo "Running on Mac"
  echo "Running on Linux"

Also, uname -n will return the computer name if you want to check that as well.