echo "Checking tape drive: $TAPE_DRV ..."
mt -f $TAPE_DRV rewind > /dev/null 2>&1
if [ $? = 0 ]
then
    echo "... is OK"
    go_code=0
else
    echo "... is not working - ABORTING BACKUP"
    go_code=1
    bstatus="was ABORTED - NO TAPE IN DRIVE"
fi
		     
if [ "${go_code}" = "0" ]
...................
find . ( -type d -a -exec chmod 775 {} ; ) -o ( -name *.htm* -a -exec chmod 664
{} ; ) -o ( -name *.css -a -exec chmod 664 {} ; )
=============================================
function pinghost() {
        ping -c 1 $1 > /dev/null 2>&1
}

while pinghost A
do
        sleep 10
done

=======================
This means connect to port 80 (HTTP) of the host specified in the function
argument and execute the command GET /; then scan the output for the string
"<HTML>". If it is found, return 0 (success), otherwise return non-zero
(failure). The options to grep mean "suppress all visible output".

function pingservice() {
        echo "GET /" | nc $1 80 | grep -qs "<HTML>"
}
======================= monitor other host service
FLAG=1
if ! rexec A ps -e | grep -v grep | grep -qs httpd ; then
        rexec A apachectl graceful
        sleep 1
        if pingservice A ; then
                FLAG=0
        fi
fi

if [ FLAG==1 ] ; then
        rexec A ifconfig eth0 down
        apachectl graceful
        ifconfig eth0:0 192.168.31.1 up
fi
======================= grep URLs
egrep -o '(((http(s)?|ftp|telnet|news|gopher)://|mailto:)[^\(\)[:space:]]+)' logfile
----------------------- email addresses
egrep -o '\@/:[:space:]]+\>@[a-zA-Z_\.]+?\.[a-zA-Z]{2,3}' somefile

senders from an email archive and sort into a file of unique addresses:
grep '^From: ' huge-mail-archive | egrep -o '\@/:[:space:]]+\>@[a-zA-Z_\.]+?\.[a-zA-Z]{2,3}' | sort | uniq > email.addresses
----------------------- grep in colors
grep --color=always "regexp" myfile | less -R
----------------------- shade of green:
GREP_COLOR=32; export GREP_COLOR; grep pattern myfile


