for ((c=0; c<$i; c++)); do
if [[ "$aTitle" == "${bookTitle[$c]}" ]]; then
if [[ "$aAuthor" == "${author[$c]}" ]]; then
found=true
fi
fi
done
echo $found
嗨,即时通讯相当新的shell编程,任何人都可以告诉我为什么我得到这个错误,当我运行这段代码?非常感谢。 BOOKTITLE &作者是一个字符串数组 aTitle & aAuthor是输入用户Bash if else声明错误
function add_new_book
{
echo "1) add_new_book"
found=false
echo -n "Title: "
read aTitle
echo -n "Author: "
read aAuthor
for ((c=0; c<$i; c++)); do
if [[ "$aTitle" == "${bookTitle[$c]}" ]]; then
if [[ "$aAuthor" == "${author[$c]}" ]]; then
found=true
fi
fi
done
echo $found
}
#author[$i]=$aAut}
./menu.sh: line 43: syntax error near unexpected token `done'
./menu.sh: line 43: ` done'
该错误可能在其他地方。 – devnull
执行为bash -x ./menu.sh并发布输出 – BrenoZan
我不明白问题,我的示例通过了ok –