Date: Fri, 14 Oct 2005 14:48:19 -0700 From: Drew Tomlinson <drew@mykitchentable.net> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Help Understanding While Loop Message-ID: <435027A3.8000908@mykitchentable.net>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?435027A3.8000908>