#!/bin/sh # Filename: grml-tips # Purpose: query a signature file for a specific keyword and display results # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. # Latest change: Sam Nov 11 20:01:35 CET 2006 [mika] ################################################################################ TIPSFILE='/usr/share/grml-tips/grml_tips' if ! [ -r "$TIPSFILE" ] ; then echo "Error: $TIPSFILE not found. Exiting." >&2 exit 1 fi if [ -x /usr/bin/agrep ] ; then if [ -n "$1" ] ; then agrep -d "^-- $" -i "$1" $TIPSFILE && echo "" || \ ( echo "Sorry, could not find a tip for '$1'. :-(" >&2 echo 'If you want to submit a tip please mail it to tips@grml.org - thank you!' >&2 exit 1 ) else echo "Usage: $0 " >&2 ; exit 1 fi else # workaround solution for systems without agrep :-/ if [ -n "$1" ] ; then TIP=$(awk "BEGIN { RS = \"-- \" } /$1/" "$TIPSFILE") if [ -n "$TIP" ] ; then echo "$TIP" else echo "Sorry, could not find a tip for '$1'. :-(" >&2 echo 'If you want to submit a tip please mail it to tips@grml.org - thank you!' >&2 exit 1 fi else echo "Usage: $0 " >&2 ; exit 1 fi fi ## END OF FILE #################################################################