4 ms·
> Why don't sed, awk, grep, etc.. all the Linux things work quite right? I need to add something else on macOS to get them to work like they did on Linux. If y
by exogen 5y ago
> Why don't sed, awk, grep, etc.. all the Linux things work quite right? I need to add something else on macOS to get them to work like they did on Linux.
If you mean how they work, like command line arguments and such (and not just speed), that's because macOS is based on BSD and thus using the BSD and not GNU versions. That's not really a "not right" thing, it's just different, and would be the same if you used any other BSD like OpenBSD, FreeBSD, etc.
- gfosco 5y agoYep... GNU versions are available for Mac, i.e. `brew install gnu-sed` and then `gsed` works like you'd expect.
- pxc 5y agoIf you install GNU coreutils from Nix (and maybe some other package managers, idk) you can get them with their normal PATHs, at the cost of some possible incompatibility with macOS-specific scripts that assume the bundled versions. I used GNU ones without the `g` prefix for a year or two and never ran into trouble because of it.
- frazbin 5y agono, it's definitely "not right" -- mac os ships with ancient, crippled versions of the bsd utilities, afaict simply because it's bad for open source and because they can. E.g. `man sed` then check the date at the bottom
- bink 5y agoHow often do you think utilities like sed, awk, and grep are being updated? They're virtually unchanged for 20-30 years.
- touisteur 5y agoI'll bite and talk about centos, the 'stable' distro. Take the example of 'tar' that slowly evolved and some time even changed its default behaviour. e.g. what to do when untaring a folder but there's already a symlink with the same name as the folder, do you erase the symlink and create a folder or do you untar the folder in the symlink? Between centos 5 and 7 this changed... Causing me some amount of pain. hostname stopped supporting '_' in host names. Could have raised a warning, have added a '-pedantic' option but no. hostname stopped assigning the permanent host name with the 'hostname myhostname' command and now you need to use hostnamectl. Could have left the 'old' feature and make hostnamectl whine instead, but no. ifconfig the deprecated tool subtly changed the order of fields too and now the MAC address is not in the same place as before, breaking scripts that trusted that not to change. df changed its syntax, adding or removing a new-line some time ago. Yeah thinking back we shouldn't have used the standard tools and expected them not to change. So, now, whenever I see in code review some bash person using 'standard' tools to get info that could be gathered through procfs or sysfs, I instead ask they use procfs, sysfs or ioctls and be done with it.
- fouric 5y agoHmmm, maybe "everything is text" wasn't such a good idea after all...
- colejohnson66 5y agoPowershell might be what you're looking for. Text is thrown away in favor of .NET objects (and reflection)
- fouric 5y agoYes, I'm a fan of PowerShell! (I just wish it was a Linux thing and not a Windows one...)
- jabbany 5y agoTo be fair, the last two are more from a bad design choice by *nix in general to base everything on passing around unstructured text and hoping each tool's ad-hoc schema won't change.
- fnord123 5y agoGnu grep uses Boyers-Moore for searching - it's wicked fast. BSD grep installed by default on Macos might not be using this algorithm. This 2 year old HN post shows the performance difference between Gnu grep and BSD grep on Macos: https://news.ycombinator.com/item?id=19522456 https://news.ycombinator.com/item?id=19522456
- sva_ 5y ago> How often do you think utilities like sed, awk, and grep are being updated? sed 4.8 - 15 Jan 2021 awk 5.1.1 - 28 Oct 2021 grep 3.7 - 14 Aug 2021 What am I missing here?
- exogen 5y agoMine says March 27, 2017 and it does everything I've ever asked it to? Maybe you have different standards for what qualifies as ancient and crippled.
- marktucker 5y agoFor me (on Catalina), it's May 10, 2005.
- mlindner 5y agoYes they rarely update the utilities for non-security reasons, but they do update them. I'm on Big Sur and it's March 27, 2017 for sed.
- a_lost_needle 5y agoJune 10th, 2020. What did I do wrong?
- plorkyeran 5y agomacOS ships ancient versions of GNU programs which are now GPLv3. The BSD things are kept up to date.
- kevin_thibedeau 5y agoIf only they had a few billion in spare change to write their own workalikes.