Created
June 19, 2023 19:38
-
-
Save mhaimes/e450f9884d013547860aac3a6aedbe9a to your computer and use it in GitHub Desktop.
check for how many bytes are left on a device where a particular folder exists
This file contains hidden or 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
#!/usr/bin/env bash | |
## Usage: ./available_bytes.sh # checks device where current directory exists | |
## ./available_bytes.sh /boot # checks device where /boot exists | |
if [ $# -lt 1 ]; then | |
TARGET=$PWD | |
else | |
TARGET=$1 | |
fi | |
DF_ENTRIES=$(df $TARGET | tail -n 1) | |
for entry in $DF_ENTRIES; do | |
[[ $entry =~ "%" ]] && break; | |
AVAILABLE=$entry | |
done | |
echo $AVAILABLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment