#!/bin/bash # # Requires "whatis", "cat", "grep", "tr", "less" clear [ -z $1 ]&&{ cat << ! *** "howto" - a friendler "whatis" / a more relaxed "apropos" *** by Ben Okopnik, 4/1997 Please enter a topic to search for, like: howto to stop worrying and learn to love the bomb ! exit } typeset -i answer FNAME=$(mktemp /tmp/tempfile.XXXXXX) trap 'rm $FNAME; rm /tmp/howto' 0 ALL="$@" whatis -w \*|grep -v "::"|grep -v "\(3pm\)"|grep -v "\(3ncurses\)"\ |tr -d '"' > $FNAME echo "I've found these matches to your request:" while [ 1 ] do echo echo "0." `grep -ic "$ALL" $FNAME` "for '"$@"'" count=1 for n in "$@" do echo $count"." `grep -ic $n $FNAME` "for '"$n"'" count=$(($count+1)) done echo echo "Please enter the line number to display or '$(($#+1))' to quit:" read answer clear if [ $answer -gt $# ] then clear exit fi echo "*******************************" > /tmp/howto if [ $answer = 0 ] then echo "Matches for '$ALL':" >> /tmp/howto echo "*******************************" >> /tmp/howto grep -i "$ALL" $FNAME >> /tmp/howto else echo "Matches for '${!answer}':" >> /tmp/howto echo "*******************************" >> /tmp/howto grep -i ${!answer} $FNAME >> /tmp/howto fi echo >> /tmp/howto less -P "Press 'q' to exit the viewer" /tmp/howto clear done