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 →

Get the MD5 Hash of a File with OpenSSL


This is a fairly compatible way that works on most distros of Linux and macOS without needing extra dependencies.

Quick Jump: Demo Video

You can run openssl md5 "${file}" | cut -d " " -f 2. Without cut it will return MD5(demo)= b1946ac92492d2347c6235b4d2611184, cut parses out just the hash.

There are other solutions to solve this problem but they typically require installing third party packages.

I needed to get the MD5 hash of a YAML file in a script to trigger a Kubernetes rollout when a specific annotation in a deployment config changed. The above did the trick.

Demo Video


  • 0:16 – Parsing out just the hash with cut

When was the last time you needed to get the hash of a file? 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 month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.