I have a script that's meant to check the disk usage on a particular volume and delete the oldest logfile if it's over a certain percentage. It runs fine on a Linux machine, but on a Solaris one, I get this error:
diskspace_check.sh: syntax error at line 3: `diskspace=$' unexpected
I assume this is due to some difference in syntax between the two systems, but I don't know what. Can anyone give me an idea?
Here is the whole script:
#!/bin/sh
logfile_path='log'
diskspace=$( df -h | grep '/c0t0d0s5' | awk '{ print $5 }' )
usep=$(echo $diskspace | cut -d'%' -f1 )
if [ $usep -ge 10 ]; then
del_file=$( ls -lt $logfile_path | grep -E 'cisco.log' | tail -1 | awk '{ print $8 }' )
del_path=$( echo $logfile_path"/"$del_file )
rm $del_path
echo "Removed log file $del_file from /disk2 on $(date)" |
mail -s "Alert: Log file removed from /disk2" xxxxxx@yyyyy.com
fi