Ported the Linux script to a bash script for better compatability