-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Linux Shell Scripting Cookbook, Second Edition - Second Edition
There are a lot of dictionaries on the Web that offer APIs that can be used to get a machine-readable definition of words. Let us use one of the APIs and see how to write a define script.
We are going to use curl, sed, and grep to write the define utility. There are a lot of dictionary websites, where you can register and use their APIs for personal use for free. In this example, we are using Merriam-Webster's dictionary API. Please perform the following steps:
Go to http://www.dictionaryapi.com/register/index.htm, and register an account for yourself. Select Collegiate Dictionary and Learner's Dictionary:

Log in using the newly created account and go to My Keys to access the keys. Note down the key for the learner's dictionary:

Let's go through the code for the define utility script:
#!/bin/bash #Filename: define.sh #Desc: A script to fetch definitions from dictionaryapi.com apikey=YOUR_API_KEY_HERE if [ $# ...
Change the font size
Change margin width
Change background colour