Skip to content

Instantly share code, notes, and snippets.

@Dreller
Created October 17, 2021 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dreller/742fc37a646b99416a76706cfc02894a to your computer and use it in GitHub Desktop.
Save Dreller/742fc37a646b99416a76706cfc02894a to your computer and use it in GitHub Desktop.
Get Free Space for Disks
#!/bin/bash
disks=("/dev/mmcblk0p1" "/dev/mmcblk0p2")
names=("My First Disk" "My Disk #2")
i=0
diskCount=${#disks[@]}
for (( i = 0; i < diskCount; i++ )); do
diskPath=${disks[$i]}
diskName=${names[$i]}
dfCommand=`df -h | grep -w "$diskPath"`
diskUsagePct=`echo "$dfCommand" | awk '{print $5}'`
diskFreeSpace=`echo "$dfCommand" | awk '{print $4}'`
echo "$diskName ($diskPath), Free Space: $diskFreeSpace"
done
@Dreller
Copy link
Author

Dreller commented Oct 17, 2021

Edit Arrays "disks" and "names" to indicate paths to disks and a human readable name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment