Operating System - HP-UX
1753594 Members
6501 Online
108796 Solutions
New Discussion юеВ

Re: Script with Date Calc

 
UniRock
Regular Advisor

Script with Date Calc

Hi All,

I am trying to make a script that would create some data for the next five days of the week in five different folders with names of the DAYS.
The script has to be run once a week, say Monday.

The problem is how shall I increment the date parameter to get next five DAY?

Thanks,
UniRock
6 REPLIES 6
Anoop P_2
Regular Advisor

Re: Script with Date Calc

Use caljd.sh

http://mirrors.develooper.com/hpux/caljd-2.25.sh

You'll need to learn to use it.

Credits for that script to A. Clay Stephenson.
kemo
Trusted Contributor

Re: Script with Date Calc

hi

i will give you one example

i want to create every day one file with name "file.date" for example today is 21-05-09 so the file will be file.210509 next day will be file.220509 and so on


just do

touch /tmp/file.`date +%d%m%y`


thanks
kamal
Suraj K Sankari
Honored Contributor

Re: Script with Date Calc

Hi,

Its easy to take today's date and make a directiory,
you can increment the day also by adding 1 into current date.

problem is comming when month is ending.

Suraj
UniRock
Regular Advisor

Re: Script with Date Calc

Hi All,

Actually I want to increment the day and not the date everytime, Monday, Tuesday and so on.

Thanks,
UniRock.
Hein van den Heuvel
Honored Contributor

Re: Script with Date Calc

Can you give us an example of what 'creating some data' might look like?

Any preferred implementation language?

If it is always run on Monday, and only the weekday is a variable, then you don't really need to know the actual date right?

Just pick them from a list... using perl:

$ perl -e '@days=qw(Mon Tue Wed Thu Fri); for (@days) { qx(cp x.dat $_)}'
'

Or, instead of coding up the list, look for the directories:

perl -e 'for (<*day>) { next unless -d; s/\..*$//; qx(cp x.dat $_) }'

Hope this helps some,
Hein.


UniRock
Regular Advisor

Re: Script with Date Calc

Thanks all of you..