Bash脚本意外错误EOF

时间:2013-12-05 01:35:44

标签: linux bash

我的脚本出现了文件的最后一行错误,我不确定原因:

./sampledata: line 55: syntax error: unexpected end of file

示例代码:

#!/bin/bash

temptime=$(date +"%H:%M")

usercount=0
while word in userfile
{ usercount=$usercount+1 }


counter=0
usercount=$usercount/2 #format

echo -n $temptime " |" >> numusersfile

while $counter -le $usercount
{
    echo -n "*" >> numusersfile
    counter=$counter+1
}
echo "" >> numusersfile

我正确地做了我的循环吗?或者我是如何写入文件的?我现在对此很难过..

1 个答案:

答案 0 :(得分:1)

而bash中的循环应该是这样的:

while [ $counter -le $usercount ]
do
    echo -n "*" >> numusersfile
    counter=$counter+1
done

请注意[]周围的空格,并将括号替换为dodone