我想通过所有文件脚本运行一个简单的循环,但它给了我以下错误。该脚本称为test.sh
,我在Windows上使用Cygwin 7循环浏览文件bash脚本
我的脚本:
#!/bin/bash
FILES = "/bowtie-0.12.7-win32/bowtie-0.12.7/output_635_25bp/*"
for f in $FILES
do
echo "hello world"
done
的错误是:
./test.sh: line 2: FILES: command not found
./test.sh: line 4: syntax error near unexpected token ``$'do\r''
./test.sh: line 4: ``do
运行前我在转换文件夹中的所有文件的脚本到使用dos2unix
命令的unix格式。
仍然给我的'/test.sh:4号线:做\ r'错误 – dawnoflife 2012-03-13 01:43:39
嗯...我m运行OSX,所以我不能在Cygwin中尝试它,但将该代码粘贴到我的shell并更改它适用于我的目录。你是否也dos2unix你的test.sh文件? – bcarlso 2012-03-13 01:52:29
哦,我只是这样做,它的工作。谢谢! – dawnoflife 2012-03-13 01:55:42