Loops

The for Command

The for command take the general form:

foreach loop variable (list of items)
      body of for loop statements
end

For example:

#!/bin/csh
# A Script to enable use of the wildcard with the mv command
# to rename *.for files to *.f files
# :r.f means chop off the extension and add .f
foreach file ($*)
  mv $file $file:r.f
end

The while Command

The while command takes the general form:

while condition
      body of while loop statements
end

If the initial command returns false, the body of the loop is never executed.