Code creates day 32 instead of 1st day of next month.
I am using the code below modified from a post I saw here regarding having the script write out future dates. The problem is that instead of making 8/1 it makes 7/32! Please help!
Last edited by libertyforall; 07-31-2010 at 01:24 AM..
The code is clearly a bad adaptation of a clever script to calculate yesterday's date.
It basically it would work for yesterday's date with:
But it does not work for tomorrow's date with:
Btw. I get a syntax error with "fmt -1" .
What Operating System and Shell are you using?
There may be better ways to do this depending on what Operating System and Shell you have.
As it stands the script is repairable by changing the logic to suite future dates.
The script contains a method for finding the last day of the month from the output of unix "cal". You'd need to determine whether the day in question is the last day of this month before deciding how to increment day month and year.
Ok. How exactly would I do that? I am using a C shell. Is there a way to read tomorrows date or have it print on the screen with perhaps the cal function? I could possibly use the cut command print the day. If not, how would I "change the logic to suite future dates?"
---------- Post updated at 07:44 AM ---------- Previous update was at 07:42 AM ----------
I am actually running a program that runs out 60 hours so I would need to be able to write the dates for as long as 2 days after tomorrow.
---------- Post updated at 08:34 AM ---------- Previous update was at 07:44 AM ----------
Would it be possible to use the +1 with a -j command to get the number of the day of year then convert the modified julian date back into the standard date?
---------- Post updated at 09:21 AM ---------- Previous update was at 08:34 AM ----------
Ok I found a pretty simple way to do it but I still need to have the month written numerically. How could I do it in conjuction with this command?
---------- Post updated at 09:30 AM ---------- Previous update was at 09:21 AM ----------
I'm sure that in your next post you will mention what Operating System you have and what Shell you are using.
The script posted in post #1 was clearly not "C shell".
The extended "date" functions are not available in standard unix, so we guess that you are running some sort of Linux.
---------- Post updated at 12:01 PM ---------- Previous update was at 11:56 AM ----------
My script worked for the date. the kshell script was partially borrowed script from an earlier project which I have had to modify. The line
is a dead line. In any case, I have a running Cronjob twice daily. I want to add a line to the script that searches for a file. If the file does not exist, I need to kill the job and run it again in one hour. I am running the program and 2 am and 2pm. I would want the job to run again at 3am and 3pm respectively. How could I do this and still keep the cronjob running twice daily if I killed it once?
Hi,
I am new to shell scripting and I have a requirement of getting first day of specific month.
eg i need 1st day of oct 2014
October 2014
S M Tu W Th F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
output... (4 Replies)
hello,
I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc.
I need to do it for several years and leap years as well.
What is the best way to do it ?
Thank you. (1 Reply)
Hello All,
I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer.
Any ideas would be appreciated! (5 Replies)
Hi All,
I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this.
My Requirment is as below:
Input for me will be 2000909(YYYYMM)
I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Hi everybody,
I am very new in shell and this is my first post :).
i am trying to write a script in which i want to decide some begin dates. this dates will be used by another shell scripts.
i would like to assign:
1- a variable which is a = sysdate
2- another variable b = the first day of... (6 Replies)
Hi
I need a script to get "Last working day of the month". I will pass the month and year as parameters and i need to get the last working date.
Ex
for June 2008 the last working day is 30th its monday.
for August 2008 the last working day is 29th and it is Friday.
ie the last working... (6 Replies)
I am a beginner in unix.
Can anyone tell me how to get the last day of the last month in 'yyyymmdd' format? eg. today is 20050909, I want to get 20050831.
Thanks in advance. (2 Replies)
Hi ,
I am relatively new to unix...
Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell..
This is very urgent.
Thanks for ur help... (7 Replies)