I name the shell script as "gen_weekday.sh", I put this in crontab but the weekday file cannot generate successfully.
58 17 25 07 * /aaa/home/scripts/gen_week
The weekday file is as follow:
awk: can't open 6
record number 6
1--
2--
5--
6--
7--
8--
9--
12--
13--
14--
15--
16--
19--
20--
21--
22--
23--
26--
27--
28--
29--
30--
Please help. Thanks,
Main Topics
Browse All Topics





by: bpmurrayPosted on 2006-07-14 at 14:42:50ID: 17112001
Try this:
1. Shell script:
#!/bin/sh
MON=`date '+%m'`
YEAR=`date '+%Y'`
if [ $MON -eq 1 ]
then
MON=12
YEAR=`expr $YEAR - 1`
else
MON=`expr $MON - 1`
fi
cal $MON $YEAR | grep -v "[A-Z]" | cut -c4-17 | awk -f formatit.awk - $MON $YEAR 2>/dev/null
2. Awk script (formatit.awk):
BEGIN {
MON=ARGV[2]
YEAR=ARGV[3]
}
{
for (i=1; i<=NF; i++)
print $i "-" MON "-" YEAR;
}