help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case statement with non-consecutive numbers


From: Dennis Williamson
Subject: Re: case statement with non-consecutive numbers
Date: Thu, 15 Apr 2021 16:22:35 -0500

On Thu, Apr 15, 2021, 4:17 PM <pauline-galea@gmx.com> wrote:

>
> What other options could be available besides
>
> for ((i=1; i <= 1000; i++)); do
>
> Perhaps using $(seq 1 2 20)
>
> Anything else?
>
> > Sent: Friday, April 16, 2021 at 9:10 AM
> > From: "Dennis Williamson" <dennistwilliamson@gmail.com>
> > To: "help-bash" <help-bash@gnu.org>
> > Subject: Re: case statement with non-consecutive numbers
> >
> > On Thu, Apr 15, 2021, 4:04 PM Greg Wooledge <greg@wooledge.org> wrote:
> >
> > > On Thu, Apr 15, 2021 at 03:57:42PM -0500, Dennis Williamson wrote:
> > > > On Thu, Apr 15, 2021, 3:30 PM Greg Wooledge <greg@wooledge.org>
> wrote:
> > > >
> > > > for ((i=1; i <= 1000; i++)); do
> > > >
> > > >
> > > > >
> > > > You can also use complex range specifications in the conditional.
> > > >
> > > > for ((i=1; i <= 1000 || (i > 2000 && i <= 3000); i++)); do
> > >
> > > That'll abort the loop after 1000, unless something inside the loop
> > > modifies i to jump it to 2001.
> > >
> >
> >
> >
> > Oops you're right.
> >
> > >
> >
>

Sequential c-style for loops. But that reduces maintainability due to
repetition of code.

There's no reason to use seq unless you're writing for portability.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]