Monday, October 6, 2008

Bash Shell Script To Access The International Thesaurus!

Hey There,

NOTE: As noted in tomorrow's post (???) This is actually a translator mocked up as a multilingual dictionary listed, for some reason, at the online Thesaurus. My sincerest apologies. I'll find a real international Thesaurus soon. A free one, of course :)

Today's Linux/Unix bash shell script is follow-up in our (must-almost-be-ending) series of posts on Linux and Unix Bash shell scripts to keep you from having to switch to your browser ;) The last one we did was an Updated World Weather Checker. To keep up with this list of scripts that keeps on growing, check out our other bash script posts on spewing out famous quotations on pretty much any subject, doing encyclopedia lookups, accessing the online Thesaurus, translating between different languages and, of course, using the online dictionary.

You can run this script just as easily as all the rest of them and it takes a variable number of arguments:

host # ./ computer


host # ./ computer store

Below is a screen shot of the script's output (I'm too tired to keep looking for two word entries that return results from this script or online, so I've just included the error message in the gif below).

Click the picture below to see it in its original form. It's almost exactly the same ;)

Hope you enjoy this script, and can find some use for it. Maybe one day, when all of these scripts have been tweaked, we'll throw those all into one simple menu-based shell script (?). And, as evidenced by the picture above, we'll probably be writing up a script to translate between all the extra characters not included on a standard US keyboard so that the output will show up correctly no matter what character-sets you have installed on your system!

Welcome back to the work week! Chin up! Things probably won't get any worse ;)


Creative Commons License

This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License


# - Say what you mean. Even if you don't understand it ;)
# 2008 - Mike Golvach -
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License


if [ $numargs -lt 1 ]
echo "Usage: $0 Your Thesaurus Terms"
echo "Ex: $0 fun"
echo "Ex: $0 big fun"
exit 1

if [ $numargs -eq 2 ]
args=`echo $args|sed 's/ /\+/g'`



$wget -nv -O - "<=on&NO=on&PL=on&BR=on&PT=on&RO=on&RU=on&SK=on&SL=on&ES=on&SV=on&TR=on&q=$args" 2>&1|grep -i "No results found" >/dev/null 2>&1


if [ $anygood -eq 0 ]
args=`echo $args|sed 's/%20/ /g'`
echo "No results found for $args"
exit 2

$wget -nv -O - "<=on&NO=on&PL=on&BR=on&PT=on&RO=on&RU=on&SK=on&SL=on&ES=on&SV=on&TR=on&q=$args" rel="nofollow" 2>&1|sed -e :a -e 's/<[^>]*>/ /g;/</N;//ba' -e 's/$/\n/'|sed -e '1,/Multilingual/d' -e '/See also/,$d'|sed -e '/^[ \t]*$/d' -e '/^$/N;/\n$/D'

exit 0