Add a Dry Run to a Destructive Script
/home/student/bin/purge.sh DIR deletes *.tmp files older than 7 days under DIR. Ops won't run it in production until they can see what it would delete first, and last week it choked on a file name with spaces.
Change purge.sh so that:
purge.sh DIR still deletes every *.tmp file under DIR (any depth) last modified more than 7 days ago, and prints deleted <path> for each.purge.sh -n DIR and purge.sh --dry-run DIR delete nothing and print would delete <path> for exactly the files a real run would delete.DIR (or with a DIR that isn't a directory), print a usage line to stderr and exit 2.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.
Part of Shell Scripting for Automation. Next step: Verify a Release Folder Against Its Manifest
Teaching or writing about this? Embed this lab on your page
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.