Hacker News new | ask | show | jobs
by sgarland 891 days ago
From TFA, the author mentions things like `date` having different args on Mac (BSD utils) and Linux (GNU utils). While true, you can just install GNU utils on a Mac, and get access to all of those, prefixed by g (e.g. GNU sed is launched with gsed).

Linuxify [0] is a decent shell script that does all of this for you.

[0]: https://github.com/darksonic37/linuxify

4 comments

If you use Macports (much more consistent than homebrew and much more attentive to the way MacOS works and MacOS SIP etc works) then installing the GNU utils ports gives you a standard GNU environment, so pretty close to Ubuntu/Fedora etc.

Of course, networking etc and DNS and other system services will be the native MacOS, but MacOS is a Unix. It has its own init with launchtl and DNS/mDNS with scutil and mDNSResponder.

If you already use homebrew, that works too: https://github.com/Homebrew/homebrew-core/blob/3ef7d3e13549b...
You can also do the same thing just with homebrew. I regularly replace a number of CLI utils because the BSD alternatives often have silly defaults/incompatible changes

No gsed, just sed.

Yeah, the script is just calling brew install over a list anyway.

I also outright replace sed and awk with their GNU equivalents. Better options and behavior, IMO. The only downside is if you have to share a script with someone, and then have to figure out how to make it work with stock.

Yep, used to use linuxify a few years back. But then it used to mess with my internal scripts. Anyhow, this was just a "what-if" exercise. Plus, Ubuntu was a test OS, but CentOS/RHEL were real PITA on client systems and this gives me a quick way out from spinning up a VM while still maintaining control. But agreed, if I just wanted GNU utils, I'd have just gone ahead with linuxify.