miriam english (miriam_e) wrote,
miriam english
miriam_e

matching a pattern in thesaurus output

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.

(Crossposted from https://miriam-e.dreamwidth.org/332278.html at my Dreamwidth account. Number of comments there so far: comment count unavailable)
Subscribe

  • Voting for lunatics and crooks

    Today I helped Mum and Dad make their postal vote in the QLD election. I was horrified that of the 6 candidates, 3 are anti-science morons and one is…

  • Tinkering with Puppy on a UEFI laptop

    Well, last night was definitely NOT fun, though it certainly was interesting. I spent almost 6 hours trying to resurrect my computer. The kind of…

  • Curved space

    It's 3:30am and my mind keeps ticking over the same annoying thing. I keep trying to think of some way to see gravity as curved space without it…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments