The solution by fpmurphy is amazingly compact and on-point for ksh93. If you need more portability, you can use perl:
Producing (in year.month.day format):
Observations: most of the code is debugging (reverse the debug assignments to see some details); you need the perl module Date::Manip (installed as libdate-manip-perl in Debian GNU/Linux); the module is big and slow, but it does the job easily; the perldoc Date::Manip documentation is almost 3000 lines long.
I am trying to write a script that shows every Friday in a month.
I used
cal $1 $2 | grep -v "^$" | awk '{print $6}'
It doesn't work for the frist week of Friday because calendar command output has some spaces in the first line and awk '{print $6}' doesn't work. Anybody help
me with this... (3 Replies)
Help please! I need to read the calendar and put the date of the third Friday of each month into a variable for comparison in an "if" statement. How would I do this?
Thnx,
leslie02 (10 Replies)
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)
I needed a cron job to run on the second to last friday of every month. Our servers are running HP-UX, and the HP-UX date command is pretty basic and does not have all of the fancy options that Linux date command does, and it does not have the ability at all to return future dates. So I had to... (0 Replies)
Hi Expert
Please help me to set a cron job schedule,
Ihave a job that run every 3rd Friday of the month at 1030am.
I tried to set up like this, but the job still runs every friday at 1030am.
I want the job to run every 3rd Friday of the month at 1030am only
30 10 15,16,17,18,19,20,21... (2 Replies)
Hello,
i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m
i need to write this script in php or bash or sh or mysql or perl in normal time o unix time
i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Hi,
I need all file names in a folder which has date >= 10th of last month,
Example
: files in folder
AUTO_F1_20140610.TXT
BUTO_F1_20140616.TXT
CUTO_F1_20140603.TXT
FA_AUTO_06012014.TXT
LA_AUTO_06112014.TXT
MA_AUTO_06212014.TXT
ZA_AUTO_06232014.TXT
Output:
AUTO_F1_20140610.TXT... (9 Replies)
Hello,
I need to find the date of next first Friday of the month and set as a variable in a bash script
ie -
FIRSTFRIDAY=$(date -dfirst-friday +%d)
I know date -dfirst-friday doesn't work, but unsure if I can use this / cal + awk or something else to find the right date of the... (7 Replies)
Discussion started by: summerdays
7 Replies
LEARN ABOUT OSX
ncal
CAL(1) BSD General Commands Manual CAL(1)NAME
cal, ncal -- displays a calendar and the date of easter
SYNOPSIS
cal [-jy] [[month] year]
cal [-j] -m month [year]
ncal [-jJpwy] [-s country_code] [[month] year]
ncal [-Jeo] [year]
DESCRIPTION
The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of easter.
The new format is a little cramped but it makes a year fit on a 25x80 terminal. If arguments are not specified, the current month is dis-
played.
The options are as follows:
-J Display Julian Calendar, if combined with the -e option, display date of easter according to the Julian Calendar.
-e Display date of easter (for western churches).
-j Display Julian days (days one-based, numbered from January 1).
-m month
Display the specified month.
-o Display date of orthodox easter (Greek and Russian Orthodox Churches).
-p Print the country codes and switching days from Julian to Gregorian Calendar as they are assumed by ncal. The country code as deter-
mined from the local environment is marked with an asterisk.
-s country_code
Assume the switch from Julian to Gregorian Calendar at the date associated with the country_code. If not specified, ncal tries to
guess the switch date from the local environment or falls back to September 2, 1752. This was when Great Britain and her colonies
switched to the Gregorian Calendar.
-w Print the number of the week below each week column.
-y Display a calendar for the specified year.
A single parameter specifies the year (1 - 9999) to be displayed; note the year must be fully specified: ``cal 89'' will not display a calen-
dar for 1989. Two parameters denote the month and year; the month is either a number between 1 and 12, or a full or abbreviated name as
specified by the current locale. Month and year default to those of the current system clock and time zone (so ``cal -m 8'' will display a
calendar for the month of August in the current year).
A year starts on Jan 1.
SEE ALSO calendar(3), strftime(3)HISTORY
A cal command appeared in Version 5 AT&T UNIX. The ncal command appeared in FreeBSD 2.2.6.
AUTHORS
The ncal command and manual were written by Wolfgang Helbig <helbig@FreeBSD.org>.
BUGS
The assignment of Julian--Gregorian switching dates to country codes is historically naive for many countries.
BSD November 23, 2004 BSD