./chkf: line 30: syntax error near unexpected token `elif'
'/chkf: line 30: `elif [ -f "$object" ] ; then
if [ -d "$object" ] ; then
message="$message a directory"
elif [ -f "$object" ] ; then
message="$message a regular file."
else
message="$message not a known file type"
fi
./chkf: line 38: syntax error near unexpected token `else'
'/chkf: line 38: `else
if [ -w "$object" ] ; then
write="writeable"
else
write="not writeable"
fi
有什麼不對呢?這似乎是正確的。我嘗試了很多變化,無法弄清楚什麼是錯誤的。有沒有某種無形的角色?如果是這樣,是否有命令將其剝離?
編輯:當我在頂部加入#!/bin/bash
,我得到以下錯誤:
interpreter "/bin/bash" not found
file link resolves to "/usr/bin/bash"
-bash: ./chkf: /bin/bash^M: bad interpreter: No such file or directory
你用的是什麼外殼?請發佈[最小測試用例](http://sscce.org/),而不是片段。 – outis 2010-11-15 07:04:58
@outis我正在使用bash – Strawberry 2010-11-15 07:05:27
什麼版本? 'echo $ BASH_VERSION' – outis 2010-11-15 07:06:31