Instructions on how to install the gsed command on macOS from source.
macOS Command Line Tools need to be installed on your local computer.
To install the Command Line Tools run the following command:
xcode-select --installTo obtain the GNU Sed tool source code run the following commands:
mkdir -p ~/.src/gnused
curl --silent --location --retry 3 "https://ftp.gnu.org/gnu/sed/sed-4.9.tar.gz" | tar xz --no-same-owner --strip-components=1 -C ~/.src/gnused
cd ~/.src/gnusedTo configure the source to be compiled for macOS run the following commands:
./configure --quiet --prefix=/usr/local --program-prefix=g --disable-dependency-trackingTo build the source code run the following command:
make --silent --no-print-directoryTo install the tool run the following commands:
sudo make --silent --no-print-directory installRun the following command on a terminal window:
gsed --versionAfter installing the tool you can remove the downloaded source code using the following commands:
cd ~
rm -rf ~/.srcTo replace the default sed command on macOS with the gsed command just installed run the following commands:
sudo ln -s gsed /usr/local/bin/sed
sudo ln -s gsed.1 /usr/local/share/man/man1/sed.1