4 ms·
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
by sgarland 3y 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 https://github.com/darksonic37/linuxify
- k_roy 3y agoYou 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.
- sgarland 3y agoYeah, 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.
- mook 3y agoIf you already use homebrew, that works too: https://github.com/Homebrew/homebrew-core/blob/3ef7d3e13549bdb977d180600b77d2ae02962378/Formula/c/coreutils.rb#L106 https://github.com/Homebrew/homebrew-core/blob/3ef7d3e13549b...
- rswail 3y agoIf 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.
- yashodhanmohan 3y agoYep, 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.