#!/bin/bash #-----------------------------------------------------------------------# # # # Description : The Google command line # # OS : Linux # # Requires : lynx (yum or apt-get install lynx) # # Licence : GPLv3 # # Version : 0.1.1 # # Author : Sebastien Bilbeau # # Web site : http://www.tux-planet.fr/ # # # #-----------------------------------------------------------------------# # Options LANG="en" SAFE="on" NB_RESULT=10 URL="http://www.google.com/search?num=$NB_RESULT&hl=$LANG&safe=$SAFE&q=" # Empty keyword search if [ -z $1 ] then echo "Usage: $0 keyword1" exit 1 fi # Serach keywords on Google appended=0 for searchTerm in "$@" do # Replace white spaces in the search terms searchTerm=`echo $searchTerm | sed 's/ /%20/g'` URL="$URL$searchTerm" # If number of keyword > 1 if [ $appended -lt `expr $# - 1` ] then URL="$URL"\+ else url="$URL"\&btnG\=Google\+Search\&meta\= fi let "appended+=1" done # Parse result #wget -q -U="Mozilla/5.0" -O - $URL >> result1 lynx -dump $URL >> result1 # Extract only url sed 's/ http/\^http/g' result1 | tr -s "^" "\n" | grep http| sed 's/\ .*//g' > result2 # Remove google cache and translate result cat result2 | grep -v google | grep -v "search?q=cache" | grep -v "oi=translate" > result3 # Get the number of results total=`awk '/of about/{ print $8 }' result1` echo "$total pages in total" echo "---------------------" # Print final result and clean cat result3 | sort -u rm result?