From owner-freebsd-questions@FreeBSD.ORG Fri Oct 14 21:50:56 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6D8316A41F for ; Fri, 14 Oct 2005 21:50:56 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from relay01.roc.ny.frontiernet.net (relay01.roc.ny.frontiernet.net [66.133.182.164]) by mx1.FreeBSD.org (Postfix) with ESMTP id 509FE43D48 for ; Fri, 14 Oct 2005 21:50:56 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from filter10.roc.ny.frontiernet.net (filter10.roc.ny.frontiernet.net [66.133.183.77]) by relay01.roc.ny.frontiernet.net (Postfix) with ESMTP id 7EE483642A3 for ; Fri, 14 Oct 2005 21:50:20 +0000 (UTC) Received: from relay01.roc.ny.frontiernet.net ([66.133.182.164]) by filter10.roc.ny.frontiernet.net (filter10.roc.ny.frontiernet.net [66.133.183.77]) (amavisd-new, port 10024) with LMTP id 01529-06-49 for ; Fri, 14 Oct 2005 21:50:20 +0000 (UTC) Received: from blacklamb.mykitchentable.net (67-51-164-214.dsl1.elk.ca.frontiernet.net [67.51.164.214]) by relay01.roc.ny.frontiernet.net (Postfix) with ESMTP id 3C49F3643FB for ; Fri, 14 Oct 2005 21:50:16 +0000 (UTC) Received: from [165.107.42.123] (unknown [165.107.42.123]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by blacklamb.mykitchentable.net (Postfix) with ESMTP id 374131549FC for ; Fri, 14 Oct 2005 14:50:15 -0700 (PDT) Message-ID: <435027A3.8000908@mykitchentable.net> Date: Fri, 14 Oct 2005 14:48:19 -0700 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: FreeBSD Questions Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.2 (20050629) at filter10.roc.ny.frontiernet.net Subject: Help Understanding While Loop X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2005 21:50:56 -0000 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 )) I've tested this by adding an 'echo $count' statement in the loop and it increments by one each time the loop runs. However when I attempt to call $count in an 'echo' statement after the 'done', the variable is null. Thus I assume that $count is only local to the loop and I have to export it to make it available outside the loop? What must I do? Thanks for your help, Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, & More! http://www.alchemistswarehouse.com