Skip to content

Instantly share code, notes, and snippets.

@cicero343
Last active July 14, 2024 06:30
Show Gist options
  • Save cicero343/f5c3190921cb5b3ee54cf5728f8765a7 to your computer and use it in GitHub Desktop.
Save cicero343/f5c3190921cb5b3ee54cf5728f8765a7 to your computer and use it in GitHub Desktop.
Print Available Disk Space (Linux)
#!/bin/bash
total=$(df -h /dev/sda5 --output=size | tail -1)
used=$(df -h /dev/sda5 --output=used,pcent | tail -1)
available=$(df -h /dev/sda5 --output=avail | tail -1)
echo "Total Disk Space: $total"
echo "Space Used: $used"
echo "Free Space: $available"
if
(( ${available%?} > 40 )) ;
then
echo "Sufficient Disk Space"
else
echo "Warning: Disk Space is Low on"" $(whoami)""@$(hostname)" "($(uname))"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment