Created
April 12, 2015 15:14
-
-
Save tomsmeding/0347fb560dd34fd998c2 to your computer and use it in GitHub Desktop.
Vertalen op de commandline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [[ "$#" != "3" ]]; then | |
echo "Give on the command line: from-language to-language word" | |
echo "Languages: NL EN DE FR ES" | |
exit | |
fi | |
text=$(w3m "http://www.mijnwoordenboek.nl/vertaal/$1/$2/$3" | cat) | |
startline=$(echo "$text" | grep -ne '^Vertalingen' | sed 's/:.*//') | |
text=$(echo "$text" | gtail -n "+$startline") | |
endline=$(echo "$text" | grep -ne '^Staat je antwoord er niet bij\|^Zojuist vertaald\|^Voorbeeldzinnen met' | ghead -n +1 | sed 's/:.*//') | |
endline=$(($endline - 1)) | |
echo "$text" | ghead -n "+$endline" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependency:
w3m
. Usesgtail
andghead
because it requires the GNU version of the commands, not the BSD version that osx provides. On a GNU system, you can just usetail
andhead
.