how to get the last word from file

Ned ngranic at cox.net
Wed Mar 30 17:48:02 EST 2005


This is yet to be seen!
Wow, what a syntax.
semicolon at the end of if, elif, then,
and the most apealing is that fi at the end.
Thanks a lot!
It's a totally new stuff to me.
Is there a case structure in bash? That would fit here just perfectly.

Many thanks!
Ned
----- Original Message ----- 
From: "Ralph W. Reid" <rreid at sunset.net>
To: "Speakup is a screen review system for Linux." <speakup at braille.uwo.ca>
Sent: Wednesday, March 30, 2005 1:16 PM
Subject: Re: how to get the last word from file


> On Tue, Mar 29, 2005 at 12:17:43PM -0700, Ned wrote:
>> Hi list,
>> I am using the cal command to get current month. What I need for my shell 
>> script is how many days are there in the current month, that is, the last 
>> listed date for that month is that very number.
>> How can I get that number?
>> cal | tail -1
>> and then what?
>>
>> Many thanks!
>> Ned
>
> The above command line will produce a blank line because the last line
> produced by `cal` is a blank line.  If you are looking specifically
> for days in the current month (as opposed to a more general
> last-word-in file search), the following is one of several ways to
> produce it:
>
> if [ `cal | grep -c 31` == 1 ];
> then
> echo 31
> elif [ `cal | grep -c 30` == 1 ];
> then
> echo 30
> elif [ `cal | grep -c 29` == 1 ];
> then
> echo 29
> elif [ `cal | grep -c 28` == 1 ];
> then
> echo 28
> else
> echo Cal did not produce a calendar.
> fi
>
> HTH, and have a _great_ day!
>
> -- 
> Ralph.  N6BNO.  Wisdom comes from central processing, not from I/O.
> rreid at sunset.net  http://personalweb.sunset.net/~rreid
> ...passing through The City of Internet at the speed of light!
> _PI = 4 * ARCTAN (1)
>
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
> 





More information about the Speakup mailing list