Hungry For More?
Cheating at crosswords
Setup
In both Mac and Linux, there's a built-in list of English words. On a Mac it's at /usr/share/dict/words
On Ubuntu you may need to apt install the wordlist
package to add it. If that doesn't work, try wamerican
or wbritish
for the spelling variant of your choice. It should available at /usr/share/dict/words
or /usr/dict/words
Run cat /usr/share/dict/words
to see the whole list of words.
Read about Unix pipes from the https://en.wikipedia.org/wiki/Pipeline_(Unix)
Challenge 1
Count how many words (lines) in the words file using the built-in wordcount wc
command. Use a pipe to take the result of cat
and input into the wc
command. Use man wc
to see the manual for how to use wordcount to count the number of lines.
Challenge 2
Take a look at the grep
command, this is used for searching for patterns of letters or characters. Here's a tutorial.
Let's say you're trying to solve a crossword and the clue isn't helping you it's "three in a line" what could that be? Fortunately you've solved enough of the crossword to know that it contains the letters yzy
.
Write a line of bash to list all words that contain yzy
.
Challenge 3
The ps
command will show a list of all the processes that are running on your computer.
Run ps aux
to see a list of all processes, even the ones not attached to a terminal and include the user name.
Are you running Chrome (open it if you're not)? Use ps aux
, grep
and wc
to find out how many processes Chrome is running. Try opening some more tabs in Chrome (with different sites) and running it again.
Challenge 4
The clue is "secondary person" and you have enough letters to know it looks like this: _ _ _ t _ _ a _ _ _ i _ t
Use words and grep to find the answer!
Challenge 5 (hard)
The clue is 'spinner' and all you know is that it's a 7-letter palindrome (yes, I know, that's not how crosswords work).
Write a regular expression which lets grep
find all 7-letter palindromes in the words file.
Last updated
Was this helpful?