Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Scrape the Word of the Day on the Command Line with curl

scrape-the-word-of-the-day-on-the-command-line-with-curl.jpg

Sometimes I like knowing the word of the day and wanted a quick way to grab it on the command line without too many dependencies.

Quick Jump:

Here’s the script that I use from DotFriedRice to grab the word of the day from the Webster dictionary. I’ve been using it for almost a year now and it’s been stable:

#!/usr/bin/env bash
# Get the word of the day with its definition.

DATA=$(curl --silent https://www.merriam-webster.com/wotd/feed/rss2)
WORD=$(sed -n 's|.*<title><!\[CDATA\[\(.*\)\]\]></title>.*|\1|p' <<<"${DATA}" | head -1)
DEFINITION=$(sed -n 's|.*<merriam:shortdef><!\[CDATA\[\(.*\)\]\]></merriam:shortdef>.*|\1|p' <<<"${DATA}" | head -1)

echo "$(date "+%F") :: ${WORD} :: ${DEFINITION} :: https://www.merriam-webster.com/dictionary/${WORD}"

When you run it, you’ll get results back like this on 1 line:

2026-11-04 :: fulsome :: generous in amount, extent, or spirit :: https://www.merriam-webster.com/dictionary/fulsome

The WORD and DEFINITION patterns with sed extract the information we want from this curl output from the RSS feed:

  • WORD: <title><![CDATA[fulsome]]></title>
  • DEFINITION: <merriam:shortdef><![CDATA[generous in amount, extent, or spirit]]></merriam:shortdef>

The goal is to extract specific text within those CDATA attributes. It looks complicated because we’re dealing with escaping a literal [ a bunch of times and are also using capture groups within \( ... \). We’re using |p to print the line if we find a match and are using | instead of / as a sed delimiter since our search string has / (it avoids escaping them).

I don’t run it all the time but sometimes it’s fun. Most of the time the definition is enough but I added a link back to the word on Webster’s site for more details.

I like it because it’s simple and stateless. You could have this run every morning and append the results to a file if you were interested in keeping the history but for me, it’s more of a “I wonder what today’s word is” which I might randomly run a few times per month.

The video shows the script in action and breaks down the sed commands.

# Demo Video

Timestamps

  • 0:07 – Demoing the script
  • 0:34 – Breaking down the script
  • 2:57 – Breaking down the sed commands

Will you end up using this? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments