Real World vs Theory Lessons
In theory, checking disk usage looks simple — just grab the percentage from df -h. But in the real world, scripts break, formats differ, and human‑readable values like 374G don’t compare cleanly. T...

Source: DEV Community
In theory, checking disk usage looks simple — just grab the percentage from df -h. But in the real world, scripts break, formats differ, and human‑readable values like 374G don’t compare cleanly. This post is about the lessons learned when theory meets reality. Disk Usage Monitoring in Linux: Percentage vs. Actual Size Monitoring disk usage is one of the most common tasks for system administrators and developers. But there’s often confusion between checking percentage usage (df -h) and checking actual disk space (du -sh with numfmt). Let’s break down the challenges, solutions, pros, and cons of each approach. ❓ Common Questions Should I monitor disk usage by percentage or by actual size? Why does my script fail with “integer expression expected” errors? How can I compare human‑readable sizes like 192K, 374G, or 2T against thresholds? Which method is more reliable across different environments (Linux, Git Bash, macOS)? ⚡ The Challenge Using df -h with percentages A typical script might