Day-03:shell编程3个实例

本文提供三个bash shell编程实例:1) 创建一个菜单驱动程序,包括显示当前目录、运行文件名、日期时间等选项;2) 编写一个脚本根据输入的成绩显示对应的等级;3) 判断用户输入是否为有效目录并输出其内容。实例中重点运用了case和if条件判断,强调了bash shell中的特殊用法和注意事项。
摘要由CSDN通过智能技术生成

实验题目:

1. 设计如下一个菜单驱动程序,保存为: menu.sh

Use one of the following options:

P:To display current directory

S:To display the name of running file $0

D:To display today's date and present time(如:2017-04-26 05:45:12)

L:To see the list of files in your present working directory

W:To see who is logged in

I:To see the ip address of this local machine

Q:To quit this program

Enter your option and hit:

要求对用户的输入忽略大小写,对于无效选项的输入给出相应提示。要求使用case

 

2. 编写一段bash shell程序,保存为:score.sh

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值