Earlier quoted context omitted.
Your cute one-liner for 4 words: sort --random-sort /usr/share/dict/words | head -n 4 | tr -d '\n' You may wish to omit words that have "'" characters, in which case you may throw in a grep -v "'" after the sort.
Thank you. I think it's a testament to the power of unix that two different people responded with solutions using different commands. I should have thought of sort, it feels natural in retrospect. Am I right in believing bash pipes are lazy enough that that won't require sorting the whole file, just pulling out four random lines? As a side note, I'm guessing grep had -v before it became a standard for verbose? That's…
edit: This stack exchange seems to relevant https://stackoverflow.com/questions/45326901/lazy-non-buffer...
I don't think grep was originally open source. FWIW, the nemonic for -v on grep is inVert. I'm so happy that --long_options are a thing nowadays, much more readable.