GNU date vs BSD date

I usually develop and test my BASH scripts on my mac, mostly for use on RedHat systems. Occasionally I run into problems with this workflow. Recently I realized there was a differnce between the date command on RedHat and the date command in OS X. Turns out BDS date != GNU date. The workaround, install coreutils from Mac Ports, and add this alias to my .bashrc:

alias date=”/opt/local/bin/gdate”

 

Update: gdate is part of the GNU coreutils, and the MacPorts install command for gdate is: sudo port install coreutils

, ,

One Response to GNU date vs BSD date

  1. chngthengteng April 27, 2012 at 10:00 am #

    Thank you, this was very helpful!

Powered by WordPress. Designed by WooThemes