Date: Tue, 9 Jul 2002 12:04:20 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: David Smithson <david@customfilmeffects.com> Cc: FreeBSD-Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: How do I repeat a command N times? Message-ID: <20020709170420.GD20718@dan.emsphone.com> In-Reply-To: <003101c22768$80ddb250$0801a8c0@customfilmeffects.com> References: <003101c22768$80ddb250$0801a8c0@customfilmeffects.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jul 09), David Smithson said: > Hello friends. I want to repeat a command 607 times and stop. How do I > accomplish this besides writing a script that's 607 lines long? Lots of ways. for i in `jot 607` ; do mycommand done This gets unwieldy if you want to loop, say a million times, since the jot command creates a string made up of all the numbers separated by spaces. A bit more complicated, but scales better: i=1 while [ $i -le 607 ] ; do mycommand i=$((i+1)) done If you're using zsh, you can use repeat 607 ; do mycommand done , but it's not portable to all shells like the while loop. -- Dan Nelson dnelson@allantgroup.com 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?20020709170420.GD20718>