set i = 1
while ( $i < 5)
echo "i is $i"
@ i++
end
or
set i = 1
while (1)
echo "i is $i"
@ i++
if ($i >= 5) break
end
This outputsThese output:
i is 1
i is 2
i is 3
i is 4
csh is largely superseded by the sh-shells nowadays, especially on the Linux platform (where the use of csh never really was widespread to begin with). Most BSDs also offer sh-compatible shells as their default interactive shell.
If you're learning shell programming, do consider learning the sh shell, unless your work requires you to grok csh and tcsh scripts (in this case, you may use a sh shell, like bash, as your interactive shell regardless of what types of scripts you work with).