[Smaug] A quick scripting puzzle
Peter Belew
abcruzww at gmail.com
Fri Nov 18 11:19:25 PST 2005
That one doesn't work all the time. Try
cal 10 2005 | tail -2 | head -c2
You get the Sunday before the last one. 'cal' outputs a constant
number of lines, so there is variable padding at the bottom.
I took care of that in my implementation, to be published
publicly after I see a few more responses.
BTW if you try
cal 9 1752
you'll see even more blank lines. :) We can thank Lord
Chesterfield for that one (as well as Pope Gregory et al.)
(BTW thanks to James for suggesting the trick that solved that one
in my solution).
- Peter
On 11/18/05, Dash McElroy <dmcelroy at bayfed.com> wrote:
> I matched it:
>
> LASTSUNDAY=`cal|tail -2|head -c2`
>
> v.s.
>
> LASTSUNDAY=`cal|rev`|rev|cut -b-2
>
> -Dash
>
>
> On Nov 18, 2005, at 9:03 AM, Rick Moen wrote:
>
> > Quoting Anthony Ettinger (apwebdesign at yahoo.com):
> >
> >> echo `cal|rev`|rev|cut -b-2
> >
> > Elegant! I suspect that's going to be difficult to beat.
> >
> >
> > _______________________________________________
> > Smaug mailing list
> > Smaug at lists.svlug.org
> > http://lists.svlug.org/lists/listinfo/smaug
> > Smaug home page: http://www.scruz.org/
>
>
> _______________________________________________
> Smaug mailing list
> Smaug at lists.svlug.org
> http://lists.svlug.org/lists/listinfo/smaug
> Smaug home page: http://www.scruz.org/
>
>
More information about the Smaug
mailing list