Photos : 25/06/2010


Latest Post
Friday, June 18, 2010

Photos : 18/06/2010


Photos : 18/06/2010
Wednesday, June 09, 2010

Spanish to English bash script


Spanish to English bash script

I just made a simple bash script that takes a word in spanish as parameter and outputs its English translation and definition taken from the wordreference service.

The code:

1 #!/bin/bash
2
3 #One param has to be recieved !
4 if [ $# -lt 1 ]; then
5 echo -e "Error:\n USO: $0 palabra"
6 exit 1
7 fi
8
9
10 oFile="$HOME/wordreference_$RANDOM$RANDOM"
11
12 agent="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100402 Namoroka/3.6.3"
13
14 #Only for es->en
16
17 upperLimit="Espasa\ Calpe:"
18 lowerLimit="Forum\ discussions\ with\ the\ word"
19
20
21
22 #Output the word !
23 lynx -dump -useragent="$agent" "$wfURI" &> "$oFile"
24
25 #Number of lines
26 nLines=`cat $oFile | wc -l`
27
28 #Now let's cut the output to the desired
29 sed -n "/$upperLimit/,/$lowerLimit/p" "$oFile" | sed "/$upperLimit/D" | sed "/$lowerLimit/D"
30
31
32 rm $oFile &> /dev/null


Download:
here

In action:


















I'm not affiliated or have anything to do with wordrefenrece.com

Tuesday, June 08, 2010

Photos : 2010/06/08


Photos : 2010/06/08

Blogger templates

A cœur vaillant rien d'impossible.
Powered by Blogger.

Labels

About