我对 shell 编程很陌生.. 并且正在做项目
我正在使用选择菜单Select Case
下面是脚本
#! /usr/bin/bash
echo "1) Add new book"
echo "2) Remove existing book info"
echo "3) Update book info and quantity"
echo "4) Search for book by title/author"
echo "5) Process a book sold"
echo "6) Inventory summary report"
echo "7) Quit"
PS3="Please enter your option: "
select book in Add Remove update search process inventory quit
#read book
do
case $book in
1) echo "Add new book"
echo "Title: "
read title
echo $title > BookDB.txt
echo "Author: "
read name
echo $name > BookDB.txt
echo "$title successfully added!"
break
;;
2) echo "Remove existing book info"
sed '$NAME' BookDB.txt
break
;;
3) echo "Update book info and quantity"
echo "Title: "
read title
echo $title < BookDB.txt
echo "Author: "
read name
echo $name < BookDB.txt
break
;;
4) echo "Search for book by title/author"
break
;;
5) echo "Process a book sold"
break
;;
6) echo "Inventory summary report"
break
;;
7) echo "Quit"
exit
;;
esac
done
下面是shell commands
在Ubuntu terminal
1) Add new book
2) Remove existing book info
3) Update book info and quantity
4) Search for book by title/author
5) Process a book sold
6) Inventory summary report
7) Quit
1) Add 3) update 5) process 7) quit
2) Remove 4) search 6) inventory
Please enter your option: 1
Please enter your option:
输入 1 后不会出现中的单词。echo
即使我选择退出,它也不会返回菜单。我如何让它工作?:(
任何帮助是极大的赞赏。谢谢!:)