All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Samuel <samuel@bcgreen.com>
To: "Scott@Charter" <scott.smallsreed@charter.net>
Cc: Linux-Admin-Group <linux-admin@vger.kernel.org>
Subject: Re: bash question
Date: Sun, 18 Apr 2004 18:42:05 -0700	[thread overview]
Message-ID: <40832E6D.7020809@bcgreen.com> (raw)
In-Reply-To: <012b01c41782$a2344b60$020aa8c0@Scott>

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.


      parent reply	other threads:[~2004-04-19  1:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01  0:45 bash question Scott@Charter
2004-04-01  7:03 ` Luca Ferrari
2004-04-01 14:58   ` Jeff Largent
2004-04-01 19:46     ` Chuck Harding
2004-04-01 22:53       ` Glynn Clements
2004-04-02  9:32         ` urgrue
2004-04-03 18:19         ` Nico Schottelius
2004-04-19  1:07 ` Joao Victor A. Di Stasi
2004-04-19  1:14   ` Joao Victor A. Di Stasi
2004-04-19  1:42 ` Stephen Samuel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40832E6D.7020809@bcgreen.com \
    --to=samuel@bcgreen.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=scott.smallsreed@charter.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.