How to use for loops in command prompt in csh shell -- looking for decent one liners

vehomzzz picture vehomzzz · Oct 9, 2009 · Viewed 12.3k times · Source

coming from bash shell, I missed on an easy rolling of loops (for i in (...); do ... done;)

Would you post typical one-liners of loops in cshell?

ONE LINERS PLEASE, and not multiple-lines thx

Answer

Dennis Williamson picture Dennis Williamson · Oct 10, 2009

The csh man page states:

The foreach, switch, and while statements, as well as the if-then-else form of the if statement require that the major keywords appear in a single simple command on an input line as shown below.

and

Both foreach and end must appear alone on separate lines.

and

The words else and endif must appear at the beginning of input lines; the if must appear alone on its input line or after an else.

and

The while and end must appear alone on their input lines.