对于这个csh
脚本
#!/bin/csh
foreach file in (.)
echo "$file"
end
我遇到了这个错误。
foreach: Words not parenthesized.
我该怎么修复这个问题?
我发现csh在将文件分割为它们自己的迭代(它会将所有文件都汇集成单个字符串,并在其中插入EOL!不过也说不准...)时出了问题,因此我不得不使用以下显式调用ls
:
foreach file ( `ls /path/to/directory/` )
echo "/path/to/directory/$file"
end
for file in .; do echo $file; done
。 - Barmar