2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by masijade
0

There is a tutorial "pasted" to the top of this forum. Otherwise, this sounds far to much like homework for me to even want to give you any other answer.

0

Hi All,

A simple questions, can someone let me know the syntax of for loop e.g if i want to print my name 100 times ?

Thanks in advance.

Actually thing is that i have tried various syntax but seems nothing is working for me, although it is a novice question, but it is getting on to me :(, one of the exampls which i tried is,

#! /bin/sh
for ( i=0; (i>10); i++ )
do
echo "$i :"
done

Error which i got is below,

syntax error at line 2: `(' unexpected


Any help

0

Well, don't put i > 10 in parens.

Edit: You also realise (I hope), that you are setting i to zero in the first part of that, and incrementing i in the last part. In the second, you are saying that the loop should continue to run as long as i is greater than 10, but since you set i to zero in the first part, it exits the loop before ever doing anything. I assume you meant i < 10. I.e. the loop should continue running as long as i is less than ten.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.