DEV Community

Discussion on: The Unix way... or why you actually want to use Vim

Collapse
 
ferricoxide profile image
Thomas H Jones II
cat /usr/share/dict/words | grep bob | shuf | head -1 | \
  parallel open https://en.wiktionary.org/w/index.php?title={}

The (notionally) more portable — and less abusive of felines — method would be something like:

grep bob /usr/share/dict/words | shuf -n 1 | \
  xargs -I {} curl https://en.wiktionary.org/w/index.php?title={}

Thankfully, shuf lets you limit the amount of lines output ...meaning you can save yourself the scads of resources of calling head! =)

Or, if you want to avoid helpers like xargs or parallel altogether:

curl "https://en.wiktionary.org/w/index.php?title=$( grep bob /usr/share/dict/words | shuf -n 1 )" 

If you're going to abuse a cat, do so by trying out multiple skinning-methods. =)

Collapse
 
gypsydave5 profile image
David Wickes

All very true, and very good!

If you're going to abuse a cat, do so by trying out multiple skinning-methods.

🤣