GNU sed on macOS

sed(/usr/bin/sed) on macOS and GNU sed are different. How to install GNU sed:

1
brew install gnu-sed

GNU sed will be located in /usr/local/bin/sed. You can use gsed in terminal.

Or you can install GNU sed by the following command to use GNU sed by default.

1
brew install gnu-sed --with-default-names