Shell编程(创建菜单并将其定向到菜单本身) [英] Shell Programming (Creating Menu and directing it to menu itself)

查看:93
本文介绍了Shell编程(创建菜单并将其定向到菜单本身)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在shell编程中创建一个菜单,其中包含一个类似这样的主菜单.

1)添加新书
2)删除现有的图书信息
3)更新图书信息和数量
4)按书名/作者搜索书
5)处理售出的书
6)库存汇总报告
7)退出


每个选择都应该将我带到该页面的下一页.
有人有示例源代码吗?我尝试使用Google搜索,但也找不到所需的教程.也许我缺乏对Shell编程的了解,我也需要知道是否能够选择一个菜单,该菜单会将其定向到该特定菜单,也许存储在另一个.sh文件中?

非常感谢:)

I''m supposed to create a menu in shell programming comprises of a main menu something like this..

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


Each selection supposed to bring me to next page of it.
Anyone had the sample source code of it? I tried googling it around, can''t find the desired tutorial for it too. Perhaps my lack of understanding on shell programming, I need to know too on be able to select a menu, which would direct it to that particular menu, perhaps stored at another .sh file?

Thanks a lot :)

推荐答案

由于您提到了.sh文件,所以我想您的意思是Unix或Linux shell脚本.尽管您可以使用几种不同类型的Shell语言-sh/bash,tcsh/csh,ksh ...

对于它们中的任何一个,查找信息的最佳位置是手册页-在命令行中使用"man bash"或"man csh".
Since you mention a .sh file, I guess you mean Unix or Linux shell scripting. There are several different types of shell language that you could be using though - sh/bash, tcsh/csh, ksh ...

For any of them the best place to look for information is the manual page - use "man bash" or "man csh" from the command line.


使用以下代码:menu.sh

Use the below code: menu.sh

# ***** Code Starts here *****

until [ "


verify" = n] 做 回声"1)添加新书" 回声"2)删除现有的图书信息" 回显"3)更新帐单信息和数量" 回声"4)按书名/作者搜索书" 回声"5)处理出售的书" 回显"6)库存汇总报告" 回声"7)退出" 回显选择菜单" 读取模式 情况
verify" = n ] do 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" echo "select a menu" read pattern case


这篇关于Shell编程(创建菜单并将其定向到菜单本身)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆