Hello everybody...
I'm a Unix newbie and i just got this task at work to figure out what's wrong with a daily script my team is using.
The idea behind the script is that it takes the day before in a
yyyymmdd format, find files with that date in a specific directory and executes an (irrelavant) operation on them.
The problem with the script is that it won't work in every 1st of every month. So in every 1st of each month they need to change the script manualy.
I think that it has to do with the $d-1 section so in eache 1st of the month it thinks that the day before is 0.
My task is to figure out a way to change the script so it will work every day of the month including the 1st of every month.
It's my first day on a new job and i dont know anything about scripting so please be gentle. I'd appreciate it if you could find a way to correct it and explain it to me.
The relevant lines are these:
d=`date '+%d'`
d=`/usr/bin/expr $d - 1`
if [ $d -lt 10 ]
then
DATE=`date '+%Y%m'`0$d
else
DATE=`date '+%Y%m'`$d
fi
DATE='20060831'
cd ${root_dir}
num=`ls -1 dec_${DATE}*|wc -l`>/dev/null
if [ $num -lt 21 ]
#if [ $num -lt 1 ]
then
Plz help...
Thx in advance !!!!