Using csh
or tcsh
, this would iterate over all the files and directories in the current directory. I've used quotes around the $i
variable substitution in case some of the names have spaces.
foreach i (*) abc "$i" end
If you'd like to get only the files, not the directories, use the -f
test. Here I've used the C shell's short-form if
statement.
foreach i (*) if (-f "$i") abc "$i" end