Need to delete the log files when the disk used% greater than 85% using df -k

Hi,
I am new to Shell scripts.
I have an urgent requirement to find the disk space using "df -k".
from that output,I need to check the used% whether greater than 85%.
if it is greater than 85% then need to delete my log files.
It is very urgent please some one help me.
Thanks in Advance
Anandbarnabas

You didn't specify your OS and the output of df varies from system to system.

Many OS support a -P (POSIX output format) and this is my best bet at getting something working for you:

df -P | awk 'NR != 1 { sub("%",""); print $5, $6}'| while read PERC FILESYSTEM
do
# Test each FILESYSTEM PERCentage against it's threshold amount.
# If PERCentage is greater than threshold then take action.

case "$FILESYSTEM" in
    /media/*) ;;
    /) ;;
    /home)  [ $PERC -gt 85 ] && rm -f /home/anandb/*.log ;;
    *) mail -s 'Invalid FILESYSTEM! found' anandbarnabas@your.email<<EOF
             
             Filesystem $FILESYSTEM has been discovered by the Diskmonitor Process. 
EOF
esac

Sorry for that :slight_smile: My OS is Solaris.