Open Luciensday opened 3 months ago
check_disk_usage() { echo "Disk Usage Information:"
# Get disk usage info using df command df -h --total | awk ' BEGIN { printf "%-20s %-10s %-10s %-10s %-10s %-10s\n", "Filesystem", "Size", "Used", "Avail", "Use%", "Mounted on" } NR>1 { printf "%-20s %-10s %-10s %-10s %-10s %-10s\n", $1, $2, $3, $4, $5, $6 } ' echo "" echo "Summary (Total):" # Display the total disk usage across all filesystems df -h --total | awk ' END { printf "Total Size: %-10s\n", $2 printf "Total Used: %-10s\n", $3 printf "Total Available: %-10s\n", $4 printf "Total Usage: %-10s\n", $5 } '
}
check_disk_usage
!/bin/bash
Function to check disk usage
check_disk_usage() { echo "Disk Usage Information:"
}
Call the function
check_disk_usage