# Get the source tarball
cd
test -f installed/grep-3.11.tar.xz && mv installed/grep-3.11.tar.xz .
test ! -f grep-3.11.tar.xz &&
wget http://ftpmirror.gnu.org/grep/grep-3.11.tar.xz
# Verify tarball w/ sha256sum:
# (this came from the info-gnu/Savannah release announcement)
# Either requires cksum from coreutils >= 9.2 or you have to do some
# extra handling because the checksum is base64 encoded
# HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=
# ->
# sha256sum grep-3.11.tar.xz | xxd -r -p | base64
# -or-
# shasum -a 256 grep-3.11.tar.xz | xxd -r -p | base64
# -or-
# openssl sha256 -binary grep-3.11.tar.xz | openssl base64
# ->
echo "1db2aedde89d0dea42b16d9528f894c8d15dae4e190b59aecc78f5a951276e\
ab grep-3.11.tar.xz" | sha256sum -c
# /bin/egrep and /bin/fgrep are small scripts
# If you do not want to see these messages every time you run them:
# warning: egrep is obsolescent; using grep -E
# warning: fgrep is obsolescent; using grep -F
# ...either update all of your scripts to use 'grep -E' or 'grep -F', or
# replace egrep and fgrep with symbolic links to /bin/grep
# ln -sf /bin/grep /bin/egrep
# ln -sf /bin/grep /bin/fgrep
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/grep-*.tar.*
mv grep-3.11.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 /bin ; rm -f egrep fgrep grep )
( cd /usr/bin ; rm -f egrep fgrep grep )
test -d /usr/doc/grep && rm -r /usr/doc/grep
find /usr/doc -mindepth 1 -type d -name "grep-*" -exec rm -r {} \;
( cd /usr/man/man1 ; rm -f grep.1 fgrep.1 egrep.1 )
( cd /usr/share/man/man1 ; rm -f grep.1 fgrep.1 egrep.1 )
rm -f /usr/info/grep.info /usr/share/info/grep.info
exit
find ~/src -maxdepth 1 -type d -name "grep-*" -exec rm -r {} \;
rm -f ~/installed/grep-*.tar.*