Linux HOWTOs

About | Home | Search


HOWTO: grep
Description: Print lines matching a pattern
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 grep 2.12
# =============
# Slackware 12.1: grep 2.5
# Slackware 12.2: grep 2.5.3
# Slackware 13.0, 13.1: grep 2.5.4
# Slackware 13.37: grep 2.7

# Prerequisites:
# iconv
# bison
# PCRE

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

# Get it
cd
test -f installed/grep-2.12.tar.xz && mv installed/grep-2.12.tar.xz .
test ! -f grep-2.12.tar.xz &&
 wget http://ftpmirror.gnu.org/grep/grep-2.12.tar.xz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "8d2f0346d08b13c18afb81f0e8aa1e2f  grep-2.12.tar.xz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "0853e96b22050cc3ff11a60e5715ca0c9852a715  grep-2.12.tar.xz" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 000BEEEE > /dev/null 2>&1 || gpg --recv-keys 000BEEEE ) &&
 wget -nc http://ftpmirror.gnu.org/grep/grep-2.12.tar.xz.sig &&
  gpg --verify grep-2.12.tar.xz.sig && rm grep-2.12.tar.xz.sig

# Extract it
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "grep-*" -exec rm -r {} \;
tar xJvf ~/grep-2.12.tar.xz
cd grep-2.12
test $UID = 0 && chown -R root:root .

# Configure and build it
./configure --prefix=/usr --infodir=/usr/info --mandir=/usr/man \
 --disable-nls
make

# Become root to install it
su

# Remove the Slackware package, if there is one, remove a few other
# miscellaneous old files
test -x /sbin/removepkg && /sbin/removepkg grep
rm -f /usr/bin/egrep /usr/bin/fgrep
find /usr/share/locale -name grep.mo -exec rm {} \;

# Install it, create egrep and fgrep symlinks
make install
ln -sf /usr/bin/grep /bin/grep
ln -sf /usr/bin/egrep /bin/egrep
ln -sf /usr/bin/fgrep /bin/fgrep

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/grep-*.tar.*
mv grep-2.12.tar.xz installed/


# If you ever want to uninstall grep (why?), this should do it:
cd
su
test -d src/grep-* && ( cd src/grep-* ; make uninstall )
( cd /usr/bin ; rm -f grep egrep fgrep )
( cd /usr/share/man/man1 ; rm -f grep.1 fgrep.1 egrep.1 )
rm -f /usr/share/info/grep.info
exit
find ~/src -maxdepth 1 -type d -name "grep-*" -exec rm -r {} \;
rm -f ~/installed/grep-*.tar.*

Back to the list


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