zsh.li Pinkhat Memories Me About ?

Dear My

Simple script for looking up words in the Terminal


When I'm reading a book there is a lot of new words that I look up in a dictionary, and it would be great to create a list of the words that I'm learning, so I do both looking up and making that list really using this script I wrote.

I use the wordnet command line utility (wn) for looking up words in English, alternatively you may use sdcv that is another useful command line utility, you only have to modify the code between parenthesis in line 5:

#! /bin/bash
while true; do
read -p "Enter a word " WORD
a=$(wn "$WORD" -over)
echo "$a"
if [ ! -z "$a" ]; then
echo $WORD >> words

This code verifies that the word exist in order to add the word in the list, when the word do not exist is returned a blank output.