From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Samuel Subject: Re: bash question Date: Sun, 18 Apr 2004 18:42:05 -0700 Sender: linux-admin-owner@vger.kernel.org Message-ID: <40832E6D.7020809@bcgreen.com> References: <012b01c41782$a2344b60$020aa8c0@Scott> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <012b01c41782$a2344b60$020aa8c0@Scott> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: "Scott@Charter" Cc: Linux-Admin-Group I'm going to presume that you want to search for a specific set of numbers, and that the fact that the fact that they're odd doesn't matter.... In that case, you'd have to use a for loop to seach thru the list of 'important' values: for $tval in 1 3 5 7 9; do if [ $a -eq $tval ] then echo -n "$a " fi done As far as I know, there's no fast way to search for one value in a list of candidates. Scott@Charter wrote: > I can't get this bash script to work. It's suppose to print all odd numbers > from 1 to 10. > > #!/usr/bin/bash > > LIMIT=10 > a=1 > > while [ "$a" -le $LIMIT ] > do > if [ "$a" -eq $(1 3 5 7 9) ] <---------Something not right here. > then > echo -n "$a " > fi > > echo > > let "a+=1" > done > echo; echo > exit 0 > > > Can anyone figure out what I am doing wrong? Can I also see the same thing > written in Perl? -- Stephen Samuel +1(604)876-0426 samuel@bcgreen.com http://www.bcgreen.com/~samuel/ Powerful committed communication. Transformation touching the jewel within each person and bringing it to light.