Punkster
Punkster

Reputation: 221

How to add a for loop instead of a foreach loop in C Shell Script?

Does a csh or a C shell script have a for loop or does it only have a foreach loop?

Can I do the following?

for($i=11; $i<=24; $i++)
{
     echo $i
}

Upvotes: 0

Views: 2294

Answers (1)

Ellis
Ellis

Reputation: 567

No, there is no for-only loop.

However, to obtain similar results, you can use a while loop:

 #!/bin/csh
 set j = 11
 while ( $j <= 24 )
   echo $j
   @ j++
 end

Upvotes: 2

Related Questions