:weather script - calling SED heads ! [longish]

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Sat Oct 2 05:39:04 UTC 2004


On Thu, Sep 30, 2004 at 10:13:30PM -0400, David J Patrick wrote:
> > >     while read a eq b; do
> > > 	case $a in 
> > > 	    celsius|conditions|humidity|pressure|wind) echo "$a = $b" ;;
> > > 	    place) place=$b ;;
> > > 	    updated) updated=$b ;;
> > > 	esac
> > > 	echo "$place @ ${updated% on *}"
> > >     done < weather.sc | sort
> > 
> > Well, there is typo here, but I'll let you find out what it is. :-)
> 
> Oh Mr Parks, you're a BAD MAN !!
> 
> ummmmm updated% should be %updated ??
> while a eq b should be $a eq $b .. ?
> the word "case" appears to be spelled backwards, near the end .. 
> 
> sigh.. I give up !
> In the old days, we'd use scisors, gluestick, non-repro blue pens and a
> photocopier .. those days are gone. I can also splice 1/4" audiotape and
> do tube registration on analog BetaCam cameras.. work with wood, wiring
> and plumbing. I play eight instruments and speak four languages, but it
> seems BASH is not one of them ...
> mebbe a clue ?

It's not so much typing error, but scripting error.

    while ...; do
	case ... in
	    ...
	esac
	echo "$place @ ..." 
    done

Here 'echo' will run for every line.  'echo' should be placed outside
the while-loop, something like

    ( while ... ; do
	...
      done
      echo "$place @ ..."
    )

This would be obvious if you actually tried to run the code. :-/

-- 
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>
Open Geometry Consulting, Toronto, Canada
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list