linux程序设计第2章末程序1
来源:互联网 发布:软件卸载大师 编辑:程序博客网 时间:2024/05/21 10:38
#!/bin/bashmenu_choice=""current_cd=""title_file="title.cdb"tracks_file="tracks.cdb"temp_file=/tmp/cdb.$$trap 'rm -f $temp_file' EXITget_return(){ echo -e "Press return \c" read x return 0}get_confirm(){ echo -e "Are you sure? \c" while true do read x case "$x" in y | yes | Y | Yes | YES ) return 0;; n | no | N | No | NO ) echo echo "Cancelled" return 1;; *) echo "Please enter yes or no";; esac done}set_menu_choice() { clear echo "Options :-" echo echo " a) Add new CD" echo " f) Find CD" echo " c) Count the CDs and tracks in the catalog" if [ "$cdcatnum" != "" ]; then echo " l) List tracks on $cdtitle" echo " r) Remove $cdtitle" echo " u) Update track information for $cdtitle" fi echo " q) Quit" echo echo -e "Please enter choice then press return \c" read menu_choice return}insert_title(){#将所有的参数写入到title_file文件中 echo $* >> $title_file return}insert_track(){ #将所有的参数写入到tracks_file文件中 echo $* >> $tracks_file return}add_record_tracks(){ echo "Enter track information for this CD" echo "When no more tracks enter q" cdtrack=1 cdttitle="" while [ "$cdttitle" != "q" ] do echo -e "Track $cdtrack,track title? \c" read tmp#将输入参数进行格式化,去除第一个逗号以及后面的内容 cdttitle=${tmp%%,*} if [ "$tmp" != "$cdttitle" ];then echo "Sorry, no commas allowed" continue fi#检查字符串是否为空 if [ -n "$cdttitle" ];then if [ "$cdttitle" != "q" ];then insert_track $cdcatnum,$cdtrack,$cdttitle fi else cdtrack=$((cdtrack-1)) fi cdtrack=$((cdtrack+1)) done}
0 0
- linux程序设计第2章末程序1
- Linux程序设计 第1章入门 第2章shell程序设计
- Linux程序设计笔记 第2章shell程序设计
- Linux程序设计 摘要(第1,2章)
- Linux程序设计第一篇1
- 萌新程序媛笔记-第1章-程序设计入门
- Linux程序设计笔记(第1章 入门)
- [Linux程序设计笔记]第12章:管道
- 《LINUX程序设计》第4章总结
- Linux程序设计(第2版)
- 第1章& 第2章 程序设计入门&循环结构程序设计
- 第2章 基本程序设计
- 第1章 程序设计基础
- 第1章 程序设计入门
- 第1章 程序设计入门
- 第1章 程序设计入门
- 《Windows程序设计》[第二版] - 第2章 Win32程序运行原理 - 创建进程
- 第1章 C语言与程序概述之1.3 程序设计
- iOS中 UIButton和UIImageView
- 深入Mysql字符集设置 图文版
- Zookeeper伪分布安装
- qmake 命令行参数
- No.2 (code 2.0)UIButton
- linux程序设计第2章末程序1
- poj 3260 The Fewest Coins
- vi编辑只读文档无法保存的解决办法
- Practical C Programming - Chapter 5
- Special的——动态规划入门教程
- Android完全退出应用程序
- [总结]FFMPEG视音频编解码零基础学习方法
- Java中Object类的clone()(克隆)方法
- 《Effective C++》资源管理:条款26-条款27