Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2005 17:13:38 -0500
From:      Will Maier <willmaier@ml1.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: Help Understanding While Loop
Message-ID:  <20051014221338.GS29905@localdomain>
In-Reply-To: <435027A3.8000908@mykitchentable.net>
References:  <435027A3.8000908@mykitchentable.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Oct 14, 2005 at 02:48:19PM -0700, Drew Tomlinson wrote:
> OK, I've been working on an sh script and I'm almost there.  In
> the script, I created a 'while read' loop that is doing what I
> want.  Now I want to keep track of how many times the loop
> executes.  Thus I included this line between the 'while read' and
> 'done' statements:

> count = $(( count + 1 ))
             ^^^ 

You're missing something here ;)

    $ count=1
    $ echo $count
    1
    $ count = $(( $count +1 ))	# note: 'count ='
    count: not found
    $ ^[[A^C
    $ count=$(( $count + 1 ))	# note: 'count='
    $ echo $count
    2

-- 

o--------------------------{ Will Maier }--------------------------o
| jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net |
| \.........wcmaier@cae.wisc.edu | \..........wcmaier@cae.wisc.edu |
*------------------[ BSD Unix: Live Free or Die ]------------------*




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