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.5.4
# ==============
# Slackware 11.0, 12.0, 12.1: grep 2.5
# Slackware 12.2: grep 2.5.3

# Prerequisites:
# iconv
# bison
# PCRE

# If ftp.gnu.org is busy, use ibiblio instead

cd
test -f installed/grep-2.5.4.tar.bz2 && mv installed/grep-2.5.4.tar.bz2 .
test ! -f grep-2.5.4.tar.bz2 &&
 wget http://ftp.gnu.org/gnu/grep/grep-2.5.4.tar.bz2

# Verify tarball w/ md5sum:
echo "5650ee2ae6ea4b39e9459d7d0585b315  grep-2.5.4.tar.bz2" | md5sum -c

# Verify tarball w/ sha1sum:
# (this came from my gpg-verified tarball)
echo "9bbd4f02b18bb264e0fcb17293b6f0445c8694d2  grep-2.5.4.tar.bz2" | \
 sha1sum -c

# Verify tarball w/ gpg:
gpg --list-keys 9F759EEC > /dev/null 2>&1 ||
 ( wget -nc ftp://ftp.gnu.org/gnu/gnu-keyring.gpg -O - | gpg --import )
wget -nc http://ftp.gnu.org/gnu/grep/grep-2.5.4.tar.bz2.sig &&
 gpg --verify grep-2.5.4.tar.bz2.sig && rm grep-2.5.4.tar.bz2.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "grep-*" -exec rm -r {} \;
tar xjvf ~/grep-2.5.4.tar.bz2
cd grep-2.5.4
test $UID = 0 && chown -R root:root .
./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 $USER .
chmod -R u+w .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/grep-*.tar.*
mv grep-2.5.4.tar.bz2 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: Fri, 26 Mar 2010 13:18:56 -0400
Jason Englander <jason at englanders dot us>