Re: [SLUG] Scripting question

From: Ronan Heffernan (ronan@iotcorp.com)
Date: Thu Sep 05 2002 - 15:42:57 EDT


Smitty wrote:
> What would the syntax be if I wanted to repeat a command n times?
> And if after repeating the command n times, follow it by another command?
> Smitty

#!/bin/bash
i=5
while test $i -gt 0 ; do
    echo "hello world"
    test $((i--))
done
echo all finished

or slightly more elegantly:

#!/bin/bash
for ((i=0;i<5;i++)); do
    echo "hello world"
done
echo all finished

--ronan



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:57:04 EDT