Storage_Unit=`du -h /var/spool/cron/root|awk '{print $1}'|sed -e "s/^.*\(.\)$/\1/"`
If [ $Storage_Unit = "G" ]
then
Size=`du -h /var/spool/cron/root|awk '{print $1}'|sed 's/.\{1\}$//'`
for Size_rounded_number in $(printf %.0f $Size); do
ROUNDED_Size=$Size_rounded_number
done
if [ $ROUNDED_Size -gt "10" ] #setting a threshold of say 10G
cp /dev/null /var/spool/mail/root
else
echo "Size in $ROUNDED_Size
fi
else
echo "storage unit in $Storage_Unit"
fi
I am getting the following error while running the script:
test1.sh: line 2: If: command not found
test1.sh: line 3: syntax error near unexpected token `then'
test1.sh: line 3: `then'
---------- Post updated at 05:12 PM ---------- Previous update was at 05:05 PM ----------
Worked it out. Their was a typo error:
If instead of if
Now getting another error:
test1.sh: line 3: syntax error at line 12: `else' unexpected