这里我从键盘获得了各种输入并检查了这些验证
Book_id必须是唯一的 主题代码只能是UNIX或C.Shell我工作的是bash
我收到以下错误
./ test.sh:line 5:声明:`= 0':不是有效的标识符
/test.sh:line 13:unix:command not found
./test.sh:line 92:语法错误:意外的文件结尾
echo -n "Enter Book Accession number: "
read Book_accession_number
declare -a var_id
declare -i i =0
subject()
{
echo -n "Enter Subject code:"
read Subject_code
if ("$Subject_code" != "unix")
then
{
if ("$Subject_code" != "c")
then
{
echo "please enter unix or c"
subject
}
fi
}
fi
subject
Book()
{
echo -n "Enter Book ID:"
read Book_id
echo -n "Enter Book Accession number: "
read Book_accession_number
declare -a var_id
declare -i i =0
while(j -ne i)
{
j++
if(var_id[i]==Book_id)
then
{
echo "please enter a unique id"
Book
}
fi
}
Book
echo -n "Enter Author Name:"
read Author_name
echo -n "Enter Year of Publication:"
read YOP
echo -n "Enter Title of Book:"
read TOB
echo -n "Enter Publisher's name:"
read PUB_Name;
echo -n "Enter Price: "
read Price
答案 0 :(得分:1)
我建议您阅读bash教程like this one。它将帮助您习惯bash语法。
答案 1 :(得分:1)
第一个是变量和=符号之间不应该放置空格。像x = 0;
第二个是在IF条件下使用[]或(())而不是()符号。
第3个,我在脚本中看不到任何第92行。我建议你尝试在代码的最后一行之后添加一个新行(空行)。