2015年1月7日 星期三

example : disk usage 超過90% , 刪除Android folder

#!/bin/sh
mkdir /cbox
mount -t vfat /dev/block/mmcblk0p7 /cbox
uspct=$(df | grep cbox | awk '{ print $5 }' | cut -d'%' -f1)
echo $uspct
if [ $uspct -ge 90 ]; then
echo 'great!'
rm -r /cbox/Android
rm -r /cbox/DCIM
fi
echo 'nothing'
umount /cbox

ref: http://stackoverflow.com/questions/19703621/get-free-disk-space-with-df-to-just-display-free-space-in-kb