---
title: "Extended Experiment With Command Line Dictionary"
description: "After my old experiments with dictionary server protocol linux rfc 2229 i just wanted to try getting a mammoth list of in JS."
url: "https://h3manth.com/scribe/extended-experiment-command-line-dictionary/"
canonical_url: "https://h3manth.com/scribe/extended-experiment-command-line-dictionary/"
markdown_url: "https://h3manth.com/scribe/blog/extended-experiment-command-line-dictionary.md"
publishDate: "2010-06-13T00:00:00.000Z"
author: "Hemanth HM"
category: "linux"
tags: ["ubuntu","bash","web","linux"]
word_count: 258
reading_time_minutes: 2
x_markdown_tokens: 499
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Extended Experiment With Command Line Dictionary

> After my old experiments with dictionary server protocol linux rfc 2229 i just wanted to try getting a mammoth list of in JS.

After my old [experiments with dictionary server protocol linux rfc 2229](http://www.h3manth.com/content/experiments-dictionary-server-protocol-linux-rfc-2229) i just wanted to try getting a mammoth list of synonyms for list of any give list, let logic behind it was pretty simple, but the pleasure that it gave was ultimate.

First off we need to install [dict](http://www.dict.org/links.html) DICT Protocol Client. For a Debian based OS, its just **sudo apt-get install dict**.[[ Read more ]](http://www.h3manth.com/content/extended-experiment-command-line-dictionary)

Now lets see the similar one liner that will make the magic happen, it's just a simple cocktail of _dict and awk_

Here are the ingredients : _0\. dict. 1\. A list of words. [ Its called wordList here ] 2\. awk. After baking we get another big list of synonyms, for each word in the list_

### **Code
    
    
     for word in $(cat wordList);  
    do dict $word | \
    awk 'BEGIN {Word=$word} /Word/,0' \
    >> synonyms; 
    done
    

**

**Dismantling the code:**

The loop and the dict command are straight forward, the only nut for us to crack is the awk part of the code.

It begins with a defining a variable called Word, which is each word looped at a time from the wordList file.

Next, we see the /Word/,0 which is nothing but the awk built-in support for range expressions _prints lines from /beginpat/ to /endpat/, inclusive_ here every pattern matching the "Word" in the output of the dict command is matched and is redirected (>) to a file called "synonyms".

Thus we end up with the fully baked file ready to eat, enjoy and do share your recipes here.
