Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
The use of Linux "date" helps for this task. However, it's not portable. I could not think of a clever method of doing this, so here's a way that uses awk and cal, both of which should be easily found on all *nix boxes:
which produces:
and:
You can make the awk shorter, but I did this way so that it would be easier to read. See man pages for details ... cheers, drl
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
The pipeline solution:
from bhargav produces:
for me. Yet for Spetember 2007:
The problem probably lies in the cut step, where the leading blank in the rows beginning with " 2" and " 9" is counted as a column ... cheers, drl
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi, Sheethal.
Let us begin with:
the shell will substitute defined values for $string, so that in the default case for today, this would become:
I suggest you run cal a few times to see how it works, especially with different arguments. Look at the output closely to see how many "fields" there are on each line of output in the calendar.
Then the shell will connect the output of cal to the next command because of the trailing "|".
We can discuss the awk script after you're comfortable with cal ... cheers, drl
PS. Apparently the email notifications are currently disabled at unix.com due to server issues, so there may be delays in communication.
Hi,
I have came across the scenario where, we have to run the script on second and fourth Monday of each month.
I have tried to search man page of date and also forum for it but, could not get any answer to this.
Can you please advise how can we get second and fourth Monday of the month?
... (18 Replies)
I have requirment to get last date of previous month and the first date of previous 4th month:
Example:
Current date: 20130320 (yyyymmdd)
Last date of previous month: 20130228 (yyyymmdd)
First date of previous 4th month: 20121101 (yyyymmdd)
In my shell --date, -d, -v switches are not... (3 Replies)
Hi
Can we get every tuesday or monday's date for the current week ?
For the current week i need tuesday's date or monday's date in
%m%d%y fromat
Thanks (5 Replies)
Hi,
I have a requirement where I want to get the date of monday when I am running the script from previous Friday to the following Thursday.
For example: When ever I run the script between 19thFeb2010(Friday) to 25th Feb 2010(Thursday), I should get the date of 22nd Feb 2010 in the format of... (5 Replies)
I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this?
How do I exclude Monday if the 2nd day of the month falls on a Monday?
Thanks.
I tried this:
0 0 2 * 0,2-6 command
And I know this doesnt... (2 Replies)
Hi
I want to extract the date on Monday depending upon the user input for that week.
For example if the input date is 20080528 then the output should be 20080526. If the input is 20080525 then it will be 20080519
i am working on IBM AIX
Thanks (2 Replies)