I'm running some operations which constantly eat up my disk space. For this reason I want my computer to make a sound when disk space is running below 2GB. I know I can get an output listing the free diskspace by running df -h
:
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 112Gi 100Gi 12Gi 90% 26291472 3038975 90% /
devfs 191Ki 191Ki 0Bi 100% 663 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
but I can't use this output in an if-then statement so that I can play a sound when the Available free space drops below 2GB.
Does anybody know how I can get only the Available space instead of this full output?
-h
fromdf
options would help here:df . | awk 'NR==2{if($4<=2*1024*1024) print "Available space < 2 GB\a"}'
– Stool