While writing up Julia Evans’ Things to learn about Linux, I thought it would be cool to display random man pages.
Which resulted in this one-liner in an executable file (man-random, invoke ./man-random):
man $(ls /usr/share/man/man* | shuf -n1 | cut -d. -f1)
As written, it displays a random page from the directories man1 – man8.
If you replace /man*
with /man1/
, you will only get results for man1 (the usual default).
All of which made me think of Geek Jeopardy!
Can you name this commands from their first paragraph descriptions? (omit their names)
- remove sections from each line of files
- pattern scanning and processing language
- stream editor for filtering and transforming text
- generate random permutations
- filter reverse line feeds from input
- dump files in octal and other formats
Looks easy now, but after a few glasses of holiday cheer? With spectators? Ready to try another man page section?
Enjoy!
Solution:
- cut: remove sections from each line of files
- awk: pattern scanning and processing language
- sed: stream editor for filtering and transforming text
- shuf: generate random permutations
- col: filter reverse line feeds from input
- od: dump files in octal and other formats
PS: I changed the wildcard in the fourth suggested solution from “?” to “*” to arrive at my solution. (Ubuntu 14.04)