From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ns1.sunset.net ([205.161.255.5] helo=onyx.sunset.net) by speech.braille.uwo.ca with esmtp (Exim 3.36 #1 (Debian)) id 1DGjco-0004Vd-00 for ; Wed, 30 Mar 2005 15:17:14 -0500 Received: from sunset.net (208-53-84-207.chico.ca.digitalpath.net [208.53.84.207]) by onyx.sunset.net (8.12.10/8.12.10) with ESMTP id j2UKE7Wi008372 for ; Wed, 30 Mar 2005 12:14:08 -0800 Received: (from rreid@localhost) by sunset.net (8.13.3/8.12.8/Submit) id j2UKGsoG019401 for speakup@braille.uwo.ca; Wed, 30 Mar 2005 12:16:54 -0800 Date: Wed, 30 Mar 2005 12:16:53 -0800 From: "Ralph W. Reid" To: "Speakup is a screen review system for Linux." Message-ID: <20050330201653.GA18561@sunset.net> References: <000801c53493$fbd20890$4e31e444@nedelko83f1172> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000801c53493$fbd20890$4e31e444@nedelko83f1172> User-Agent: Mutt/1.4.2.1i Subject: Re: how to get the last word from file X-BeenThere: speakup@braille.uwo.ca X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Speakup is a screen review system for Linux." List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2005 20:17:14 -0000 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@sunset.net http://personalweb.sunset.net/~rreid ...passing through The City of Internet at the speed of light! _PI = 4 * ARCTAN (1)