How to add foreach loop counter in csh

In the CSH foreach loop or for loop, how can I add a loop iterator or counter that increments from 10 to 1000 in increments of 20?

Something like foreach i (1..20..5) or for (i=1;i<20;i++) .

+7
source share
2 answers

If you have a seq command, you can use:

 foreach i (`seq 1 5 20`) ... body ... end 

If you don't have seq , here is a version based on @csj answer:

 @ i = 1 while ($i <= 20) ... body ... @ i += 5 end 
+8
source

Any documentation I found on the Internet seems to be indicted for not having a loop. However, a while loop can be used. I really don't know csh, so the following is approximate, based on what I read:

 set i = 10 while ($i <= 1000) # commands... set i = $i + 20 end 
+2
source

All Articles