Last active
July 14, 2024 06:30
-
-
Save cicero343/f5c3190921cb5b3ee54cf5728f8765a7 to your computer and use it in GitHub Desktop.
Print Available Disk Space (Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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