![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Use date command to find last month | Cbish68 | Shell Programming and Scripting | 5 | 08-10-2007 11:32 AM |
| find out month from a date | rudoraj | UNIX for Dummies Questions & Answers | 5 | 07-03-2007 09:21 AM |
| How to find the first day of previous month in unix? | mohapatra | Shell Programming and Scripting | 10 | 07-02-2007 09:57 PM |
| Need help, Every friday in a month | LAY | Shell Programming and Scripting | 3 | 12-09-2006 09:12 AM |
| Find all files by month | maldini | Shell Programming and Scripting | 13 | 08-03-2005 02:22 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Leslie, See if this works for you: Code:
typeset -i mMth=1
mYear='2007'
while [ ${mMth} -le 12 ]
do
m3Friday=`cal ${mMth} ${mYear} | tail +3 | cut -c16,17 | sed '/^ *$/d' | sed -n '3p'`
echo "Third Friday of "${mMth}"/"${mYear}" = "${m3Friday}
mMth=${mMth}+1
done
|
|
|||||
|
Shell_Life, akrathi, anbu23, it seems that your solutions do not work in all the cases : Code:
$ cal 12 2007
December 2007
Sun Mon Tue Wed Thu Fri Sat
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
$ cal 12 2007 | tail +3 | cut -c16,17 | sed '/^ *$/d' | sed -n '3p'
2
$ cal 12 2007 | cut -c16-18 | tail -4 | head -1
13
$ cal 12 2007 | sed -n "5{s/ *[0-9]\{2\}$//;s/^.* //p;}"
14
$
A possible solution : Code:
$ cal 12 2007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}'
21
$ cal 07 2007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}'
20
$ cal 6 02007 | awk 'NR>2 && NF>=2 && ++w==3 {print $6}'
15
$
Jean-Pierre. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|