Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!lll-winken!indri!aplcen!bink From: bink@aplcen.apl.jhu.edu (Ubben Greg) Newsgroups: comp.sources.wanted Subject: Re: Day of week routine Summary: Use SED (as always) Message-ID: <1331@aplcen.apl.jhu.edu> Date: 28 May 89 02:39:28 GMT References: <234@zeek.UUCP> <9490003@hpsal2.HP.COM> Reply-To: bink@aplcen.apl.jhu.edu (Greg Ubben) Organization: The Johns Hopkins University, Baltimore MD Lines: 19 In article <9490003@hpsal2.HP.COM> (Michael Morrell) writes: > > Nice try, but the script unfortunately relies on each week in cal's output > to have seven numbers in it. It fails on days in the first week of a month > if it does not start on a Sunday (e.g., try "dow 5 1 89"). Well I guess this discussion gives me license to post the CAL|SED solution I mailed to the original poster (entirely useless for his application I'm sure) :-) No error-checking and inefficient, but correct none-the-less. # USAGE: dow [day [month [year]]] set `date +"${1:-%d} ${2:-%m} ${3:-19%y}"` cal $2 $3 | sed -n " s/.*/SunMonTueWedThuFriSat & / 1!s/.*\([A-Z]..\).\{18\} *$1 .*/\1/p " -- Greg Ubben "A SED fanatic" bink@aplcen.apl.jhu.edu