#!/bin/sh ####################################### # google (.sh) # # version 0.1.0 # # by Paul Duncan # ####################################### ############# # temp file # ############# TF=/tmp/wget-"$USER"-"$RANDOM".html; ##################### # number of results # ##################### RESULTS=15 if [ "$1"x = "x" ]; then echo -e "Usage:\n google \"search string\" [count]" exit -1 fi Q=$1 shift; N=$1 if [ "$N"x = "x" ]; then N=$RESULTS; fi wget -O $TF -q http://www.google.com/search?q=`echo $Q|sed 's/ /+/g'`\&num=$N perl -nle 'if (/href=/i) { $t=""; $u=""; /(.*?)<\/A>/; $t=$2; $u=$1; if ($t && $u && $t !~ /^(//gi; print "$c. \"$t\":\n $u"; } }' < $TF rm $TF