Shell script - increment date variable

Hi,

I need a script that does the following:

I have a table called todo that has a column called date:
The data in it looks like this:
01-SEP-11  

So I have a table with over 3 million rows and some with  01-SEP-11   and some with 02-SEP-11 and so on...

Is there a way to do the following?

for variable=01-SEP-11
do
      output=`sqlplus -s ${db_user}/${db_pass}@${SID} <<!
            set heading off
            set feedback off
            select * from todo where date=${variable};
            exit;
            !`

      echo ${output} >> ultimate_file.txt

**Increment one day at the variable (is there a way to increment a counter for a date? like one day more?
done

=======

Tks,
Joao
joaotellesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hernst42Commented:
Do you mean something like:


for i in $( seq 1 10 ); do v=$( date --date="+$i day" +%d-%b-%Y ); echo $v; done

Open in new window

0
joaotellesAuthor Commented:
Tks.

So the big picture would be: This would increment the $v, lets say staring form 01-SEP-11 day by day?
Where can set it to start at SEP 01?
And when it comes to 31-SEP.. will it go to 01 OCT?

for i in $( seq 1 10 ); do v=$( date --date="+$i day" +%d-%b-%Y ); echo $v;
output=`sqlplus -s ${db_user}/${db_pass}@${SID} <<!
            set heading off
            set feedback off
            select * from todo where date=${variable};
            exit;
            !`

      echo ${output} >> ultimate_file.txt

done

             

0
TintinCommented:
How many days to you want to increment for?

Here's an example starting on Sep 01 and incrementing for 40 days

for i in $(seq 0 40)
do
   date=$(date --date "01-Sep-2011 + $i day" +%d-%b-%Y)
   
   output=`sqlplus -s ${db_user}/${db_pass}@${SID} <<!
            set heading off
            set feedback off
            select * from todo where date=$date;
            exit;
            !`

      echo ${output} >> ultimate_file.txt

done
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joaotellesAuthor Commented:
Tks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.