Unix Shell Scripting

Download

 

I will freely admit that I have always had a hard time with the odd syntax used in Unix Shell Scripts and often have gotten frustrated  trying to create powerful scripts.  Most of the time, I keep scripts simple and use other tools for more complex tasks.

Nonetheless, someday I plan to become more proficient at shell scripts.

#!/bin/ksh
# script to delete the previous month from the loghist 
# directory on the network
# ray 11-97
# to be run from cron

# get the last month number
zero=0
month=`date +%m` 

if [ $month == 1 ]
then
   #jan, do dec
   prevmo=12
else
   prevmo=`expr $month - 1`
fi

# add the 0
if [ "$prevmo" -le 9 ] 
then
  prevmo=$zero"$prevmo"
fi

# now purge previous month from network
ftp -v atlas << EOF
cd /sys/factedi/log/loghist
delete $prevmo*.lo?
cd /sys/titanedi
delete $prevmo*.lo?
quit
EOF

 

Email: raykelly@rakelly.com

TOP