Linux HOWTOs

About | Home | Search


HOWTO: sed
Description: GNU stream editor
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GNU sed 4.2.1
# =============
# Slackware 12.1, 12.2, 13.0: sed 4.1.5
# Slackware 13.1, 13.37: sed 4.2.1

# I have not tried it, but there is another sed called super-sed:
# http://sed.sourceforge.net/grabbag/ssed/

# If the download site used below is busy, try one of these:
# http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/sed/
# http://ftp.gnu.org/gnu/sed/

# Prerequisites:
# texinfo (makeinfo is used to build HTML documentation)
# iconv
# Bison

cd
test -f installed/sed-4.2.1.tar.bz2 && mv installed/sed-4.2.1.tar.bz2 .
test ! -f sed-4.2.1.tar.bz2 &&
 wget http://ftpmirror.gnu.org/sed/sed-4.2.1.tar.bz2

# Verify tarball w/ md5sum:
# (this came from my gpg verified tarball)
echo "7d310fbd76e01a01115075c1fd3f455a  sed-4.2.1.tar.bz2" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg verified tarball)
echo "ace93d23eabc00d3a8187ecf07d3a02b1b297810  sed-4.2.1.tar.bz2" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --recv-keys A750566F > /dev/null 2>&1 || gpg --list-keys A750566F ) &&
 wget -nc http://ftpmirror.gnu.org/sed/sed-4.2.1.tar.bz2.sig &&
  gpg --verify sed-4.2.1.tar.bz2.sig && rm sed-4.2.1.tar.bz2.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "sed-*" -exec rm -r {} \;
tar xjvf ~/sed-4.2.1.tar.bz2
cd sed-4.2.1
test $UID = 0 && chown -R root:root .

# If you don't have a sed binary installed (./configure uses it), do
# this first:
# (FYI - this did not work for me this time, but the regular build did)
sh ./bootstrap.sh
su -c "cp sed/sed /bin/"
cd ..
rm -r ./sed-4.2.1
tar xzvf ~/sed-4.2.1.tar.bz2
cd sed-4.2.1
test $UID = 0 && chown -R root:root .

./configure --prefix=/usr --bindir=/bin --infodir=/usr/info \
--mandir=/usr/man --disable-nls
make

# Become root to install it
su

# Remove old files that make cause issues
find /usr/doc -maxdepth 1 -type d -name "sed-*" -exec rm -r {} \;
rm -f /usr/info/sed.info* /usr/man/man1/sed.1*
find /usr/share/locale -type f -name "sed.mo" -exec rm {} \; 2> /dev/null
find /var/adm/packages -type f -name "sed*" \
-exec mv -f {} /var/log/removed_packages/ \;
find /var/adm/scripts -type f -name "sed*" \
-exec mv -f {} /var/log/removed_scripts/ \;

# Install the new version, the sed binary will be stripped
make install-strip

# Everything prior to Slackware 9.0, and this howto as well, put sed in
# /usr/bin.  Slackware 9.0 puts sed in /bin and creates a symlink to it
# in /usr/bin.  Makes sense, sed is important and if your /usr is actually
# a mount of a remote filesystem, sed might not exist early on during boot-up.
# So here we remove the old binary and create a symlink to the new one:
rm -f /usr/bin/sed
ln -sf /bin/sed /usr/bin/sed

# Slackware >= 9.0 has a 'sed' package, everything prior to it included sed
# in the 'bin' package.  If you have < 9.0 and are really anal (like me),
# remove lines from the /var/adm/packages/bin* file that reference sed
# files that you just replaced:
# /usr/bin/sed
# /usr/doc/sed-*
# /usr/man/man1/sed.1.gz
# /usr/info/sed.info.gz

# Make sure your non-root user can remove the source later
chown -R root:root $USER .
chmod -R u+rw .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/sed-*.tar.*
mv sed-4.2.1.tar.bz2 installed/

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>