Linux – foreach syntax in csh

cshlinuxshell

For this csh script

#!/bin/csh

foreach file in (.)
  echo "$file"
end

I get this error

foreach: Words not parenthesized.

How can I fix that?

Best Answer

There should be no in:

foreach file ( . )

Be sure to read Stop Using (and Teaching) C-Shell.