MacOS command-line - possible to write portable scripts across MacOS and Linux?

Darwin, the Unix foundation of Mac OS X, is essentially a flavor of BSD, so some of the differences you're seeing are due to that. The lack of certain tools which might be standard on most or all Linux distros can be addressed by

  • using a package manager, such as
    • MacPorts, or
    • Fink; or by
  • installing from source.

Sometimes packages are unacceptably far behind. For instance, I found a bug in tmux 1.4 that makes it unusable for me, but macports does not have 1.5 yet. So installing from source may be preferable in many cases.


The various GNU tools are available in Fink or DarwinPorts or whatnot.