37/60
Sign inSign up free

745. Disk Usage Percentages With Alerts

easy 10 XP ~8 minHands-on lab

The storage team's collector writes lines like data01 734003200 1073741824 (NAME USED_BYTES TOTAL_BYTES). Bash arithmetic is integer-only, so the old script printed 68% for 68.4 and 0% for small values.

Write /home/student/bin/disk-pct.sh [THRESHOLD] < input.

Task

  • Read lines from standard input. For each line, print NAME PCT%, where PCT is USED / TOTAL × 100 with one decimal (rounded), for example data01 68.4%.
  • If PCT is at or above THRESHOLD (default 90), append ALERT to that line.
  • A line with TOTAL of 0 prints NAME n/a.
  • Skip empty lines.

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.