miriam_e: from my drawing MoonGirl (Default)
[personal profile] miriam_e
There must be a simpler way to do this. I was looking for words similar in meaning to "back" or "previous" or "before" but beginning with the letter "d".

My awk is a bit rusty so I used sed, which I seem to use almost every day, wonderful, ugly command it is. Here is what I came up with:

dict -d moby-thesaurus back | sed -z 's/,/\n/g' | sed 's/^[[:space:]]*//' | sed -n '/^[dD]/p'

dict looks up "back" in "moby-thesaurus"
pipe to...
sed gulps it all down as a single line using the -z option and, for all commas, substitutes a newline
pipe to...
sed removes all whitespace characters from start of each line
pipe to...
sed prints only lines that start with "d" or "D"

The choice of pattern is important, for example '\<d' also finds multiple word results where one of the words starts with "d" (e.g. "lay down").

But there must be a simpler way. Jeez!
I can hardly wait for general purpose AI.

Profile

miriam_e: from my drawing MoonGirl (Default)
miriam_e

November 2018

S M T W T F S
    123
45678910
11121314151617
181920212223 24
252627282930 

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 18th, 2019 06:32 pm
Powered by Dreamwidth Studios