我正在为家庭作业编写一个 bash 脚本,它需要构建一个具有一些功能的迷你库。除了搜索功能,我几乎可以使用所有功能。第 11 行中的 if 语句始终为真。我不知道如何比较。
$lib="library"
function search_book {
echo Enter Book Title
read title
exists=`grep "$title" $library | wc -l`
if (( $exists == 0 ))
then
echo "No Such Book in Library"
else
act_owner=`awk -F, '/'$title'/ {print $3}' $library`
echo $act_owner
if (( $act_owner == $lib ))
then
echo Book Kept In $act_owner
else
echo Book Checked Out by $act_owner
fi
fi
stop=0
while (( $stop == 0 ))
do
echo
echo "=========================="
echo "(t) Try again"
echo "(b) Back to main menu"
echo -n 'Choose Option to Continue'
read reply
case $reply in
"t") stop=1; search_book;;
"b") stop=1; main_menu;;
*) echo illegal choice, enter again:
esac
done
}