View Full Version : Shell Script Equivalent C style for statement?

November 27th, 2008, 07:44 AM
Is there an equivalent shell script syntax that would mimik C's for statement syntax (for i=0; i<5; i++){....};

The best I can come up with would be something like this:
while [ c -lt 5 ]; do
c=`expr $c + 1`;

Seems like a clumsy way of doing the same thing to me??

November 27th, 2008, 08:32 AM
check out the bash guide in my sig under chapter 10, section 1. you can find example of for loop with C like syntax. Best of all, read the whole document.

November 27th, 2008, 01:49 PM
Wow -- that is good stuff, and I really learned a lot.