Date: Sun, 7 Feb 1999 21:39:57 +0000 From: Ben Smithurst <ben@scientia.demon.co.uk> To: root@isis.dynip.com Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Help About Shell Script Message-ID: <19990207213957.A1306@scientia.demon.co.uk> In-Reply-To: <199902071818.VAA63085@isis.dynip.com> References: <19990207133723.B71725@scientia.demon.co.uk> <199902071818.VAA63085@isis.dynip.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Please remember to cc all replies to the mailing list. root@isis.dynip.com wrote: > On 7 Feb, Ben Smithurst wrote: > > > i=0 > > while [ $i -le 1000 ]; do > > j=0 > > while [ $j -le 1000 ]; do > > ## do your stuff here with $i and $j > > > > j=$(($j+1)) > > done > > i=$(($i+1)) > > done > > Thanks very much. > What if we wanted to tke the variables i and j > from a file. That would depend what format the file was. At the simplest level, with two files called "current_i" and "current_j", containing the numbers alone, you can read that like so: i=$(cat current_i) j=$(cat current_j) and then proceed as normal. If the file contains something like i=5 j=18 you could probably do eval $(cat name_of_the_file) to get those variables as shell variables. If the file contains any more, you'll have to get something smarter to read it, and I'd recommend using Perl if you go much more complex. -- Ben Smithurst ben@scientia.demon.co.uk send a blank message to ben+pgp@scientia.demon.co.uk for PGP key 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?19990207213957.A1306>