✨ free-gigs: script-friendly df
This commit is contained in:
parent
4dc16bb7ba
commit
c17ba1bd8c
1 changed files with 20 additions and 0 deletions
20
free-gigs
Executable file
20
free-gigs
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# script-friendly df
|
||||||
|
|
||||||
|
factor=1024 # default
|
||||||
|
|
||||||
|
OPTSTRING="H"
|
||||||
|
while getopts ${OPTSTRING} opt; do
|
||||||
|
case ${opt} in
|
||||||
|
H)
|
||||||
|
factor=1000
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
target=${1:-.}
|
||||||
|
|
||||||
|
free_bytes=$(findmnt --df -T "$target" -oAVAIL --bytes | sed '1d')
|
||||||
|
free_gigs=$((free_bytes/(factor**3)))
|
||||||
|
echo $free_gigs
|
Loading…
Add table
Add a link
Reference in a new issue