Signal9Signal9 — home
online
back to labs

Command Substitution: Output Into a Command

MediumCommand Line Guru10-15 min
The brief

Command substitution — $(command) — runs a command and drops its output right into the line you're building. It's how a filename gets today's date, or a variable gets a computed value.

Two tasks, both under /root/out/:

1. Create a dated snapshot file named exactly snapshot-YYYY-MM-DD.txt where the date is TODAY's, produced with $(date +%F) — not typed by hand. It's a regular file in /root/out/ and must not be empty — put any text inside it (an empty touch doesn't count).

2. Create /root/out/host-report.txt whose FIRST line is the machine's kernel release, captured with $(uname -r).

Grading recomputes $(date +%F) and $(uname -r) live and checks your files match — so the values must genuinely come from the commands, not a copy-paste that goes stale tomorrow.

What you'll do
  • Name a file with today's date via $(date +%F)
  • Embed $(uname -r) output as the first line of a report

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.