Friday, May 25, 2018

Do a task if your partition usage is greater than a given percentage using shell script,Linux Teacher Sourav,Kolkata 09748184075

a=$(df -h | grep -E 'root' | awk ' { print $5 " " $1}' | cut -f1 -d " " )
echo $a

b=${a::-1}
echo $b
if [ $b -ge 90 ] ; then
echo "hello"
else
echo "nope"
fi


in terminal you do it like this

df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | awk '{ print $1}' | cut -d '%' -f1 

No comments:

Post a Comment