Append without erasing OPS-2219

OpenShell basics · Easy · Do · about 10 min ·Linux

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Mara Okafor opened OPS-2219 at 10:05task

Last week someone wiped three months of depot health history with one character. The auditors arrive on Thursday. Add today's line without losing anything.

reports/shift.txt is the depot's health history: one line per daily check, kept for the quality audit. Last Monday someone ran the health check with > instead of >> and replaced the whole file with a single line.

"Run the check once and add its result to the end. Only the health line. The warnings it prints are for whoever is watching the screen, they do not belong in the record." (Mara)

bin/healthcheck prints one health line on standard output and some warnings on standard error.

Your task

Run bin/healthcheck once and append its health line to reports/shift.txt. The earlier lines must stay, exactly one new line must be added, and no warning may end up in the file.

On the machine

  • reports/shift.txt with the two most recent lines
  • bin/healthcheck
  • TICKET.md

Timeline

Mon last weekbin/healthcheck > reports/shift.txt replaces the history with one line.
Tue last weekThe history is restored from backup, minus two days.
10:05Mara asks you to add today's check, carefully.
ThuISO 9001 auditors review the depot health record.

Done when

  1. The earlier lines of reports/shift.txt are still there.
  2. One new line from bin/healthcheck is at the end, and no warnings.

Hints

Hint 1

Run bin/healthcheck on its own first. Which lines are warnings?

Hint 2

> replaces a file; >> adds to the end.

Hint 3

Warnings go to stderr. A plain >> only redirects stdout.

Hint 4

bin/healthcheck >> reports/shift.txt

Show the solution

bin/healthcheck >> reports/shift.txt, then cat reports/shift.txt to confirm three lines.