BSD sed vs GNU sed

Warning

The version of sed that comes with macOS is not GNU sed! Many things about it are different, and some commands won't work the same! To get the "real" sed:

brew install gnu-sed

And then use gsed