Suppose you’re doing a crossword and you’re a bit stuck. You know the answer starts with an M, and you’re fairly sure it ends ING. But you can’t figure out what word it is.

Lucking, you have Linux (or some other unix) on your machine, so you can run a simple command to find the answer.

The first thing to know is that there’s a useful list of words buried away in /usr/share/dict/words. This is a text file with one word per line, and is a useful resource for all manner of language processing tasks.

You can use the grep command to search this file, supplying it with a regular expression. Simply use ^ and $ to force the pattern to match a whole line, and use . as a wildcard for any missing characters.

So, in the case of the crossword, we get the following:

$ grep ^m..ing$ /usr/share/dict/words
  • macing
  • making
  • mating
  • mawing
  • maxing
  • mering
  • meting
  • mewing
  • miking
  • miming
  • mining
  • miring
  • mixing
  • mooing
  • moping
  • moving
  • mowing
  • muling
  • musing
  • muting

So, if the clue was “Noise a cat makes” you can scan the list and pick out mewing.

Simple. Any you didn’t even have to search the Internet!