32/60
Sign inSign up free

504. Compare Two .env Files Without Leaking Secrets

medium 20 XP ~12 minHands-on lab

Staging and production configs drift apart, and someone has to find out which keys differ. The files contain secrets, so the report must never show a value.

Task

Create the executable script /home/student/bin/envdiff.sh OLD NEW for files of KEY=value lines:

  • ignore blank lines and lines starting with # (after optional spaces),
  • a value runs to the end of the line and may itself contain =,
  • print one line per difference, sorted by key:
    • + KEY if the key is only in NEW,
    • - KEY if the key is only in OLD,
    • ~ KEY if it's in both with different values,
  • exit 0 if there are no differences, otherwise 1,
  • never print any value.

/home/student/env/staging.env and /home/student/env/prod.env are there to try it on.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.