我正在尝试在 Windows 7 上的 cygwin 中运行以下 bash 脚本
REPEATTIMES="$1"
if [ $# = 0 ]; then
echo "Usage: fetch topN repeatTimes"
exit 1
fi
for (( i=1; i<=$REPEATTIMES; i++ ))
do
echo "ITERATION: $i"
echo "GENERATING"
log=thelogs/log
bin/nutch generate crawl/segment -topN 10 > $log
batchId=`sed -n 's|.*batch id: \(.*\)|\1|p' < $log`
echo "batch id: $batchId "
# rename log file by appending the batch id
log2=$log$batchId
mv $log $log2
log=$log2
echo "FETCHING"
bin/nutch fetch crawl/segments/$batchId >> $log
echo "PARSING"
bin/nutch parse crawl/segments/$batchId >> $log
echo "UPDATING DB"
bin/nutch updatedb crawl/crawldb crawl/segments/$batchId >> $log
echo "Done "
done
但是当我运行它时,我得到了错误:
line 11 :syntax error near unexpected token '$'\r'
line 11 :'for (( i=1; i<= REPEATTIMES; i++ ))
该脚本在 ubuntu 服务器上运行良好。但我现在需要在 Windows 机器上运行它。