:wall:Hi
I am a beginner to unix
In a shell script i see the below code
# set admin email so that you can get email
ADMIN=someone@somewhere.com
host=`hostname`
date=`date`
# set alert level 70% is default
ALERT=70
df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output;
usep=`(echo $output | awk '{ print $1}' | cut -d'%' -f1 )`
partition=`(echo $output | awk '{ print $2 }' )`
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on "$host" as on "$date |
mailx -s "Alert: Almost out of disk space $usep" $ADMIN
fi
done
As we can see the script is send an alert email to the user when disk space exceeds 70%.
what I could not under stand is below line
df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
we are diverting the modified df -h output to "while loop output". what does this mean?
how many times the loop is executed?
please provide any guidance.
thanks
p.