foreach syntax in csh

10,430

There should be no in:

foreach file ( . )

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

Share:
10,430
mahmood
Author by

mahmood

Updated on June 13, 2022

Comments

  • mahmood
    mahmood almost 2 years

    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?

  • Demis
    Demis almost 2 years
    FYI, some people may be forced to use CSH due to vendor hardware - as in the case of ASML equipment, for example. ( wiki.nanotech.ucsb.edu/wiki/Stepper_3_(ASML_DUV) ) Installing new shells (or installing anything in general) is not recommended on such equipment to ensure functionality is not compromised. I do entirely agree though - I wish I could use something other than CSH!