Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2001 19:58:48 -0500
From:      Mike Meyer <mwm@mired.org>
To:        Mark Drayton <mark.drayton@izr.com>, bill <bill@maine.60north.net>
Cc:        questions@freebsd.org
Subject:   Re: sh for loop
Message-ID:  <15188.57160.799562.343400@guru.mired.org>
In-Reply-To: <52572270@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Mark Drayton <mark.drayton@izr.com> types:
> Hi
> As part of a shell script I need to write a for loop that iterates from
> 1 to 10 inclusive. I know I can use this:
> 
> for i in 1 2 3 4 5 6 7 8 9 10; do
> 	echo $i
> done

bill <bill@maine.60north.net> types:
> I would do this... 
> INC=`expr $INC + 1` 
> cheers!

Personally, I'd use jot:

for i in `jot 10`
  do
    echo $i
  done

See the jot man page for more information.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15188.57160.799562.343400>