OlveraeUNSW
Back to problems
COMP2041

22T2 Q5 — Log rotation

Argument $1 is a date string. In the current directory: if log.6 exists, move it to archive/<DATE>.log (create archive/ if needed); then shift log.5→log.6, log.4→log.5, …, log.1→log.2, log→log.1 (only files that exist). Print nothing.

Special handling: the original uses today's date and gzip; here the date is $1 and the archive is uncompressed, so the rotation is graded deterministically.


POSIX shell only (#!/bin/dash); standard UNIX filters. From COMP2041/9044 — adapted for deterministic autotest.

Samples

stdin
expected
shell
14