LINUX-Shell编程实验报告.docx

上传人:rrsccc 文档编号:9836884 上传时间:2021-03-29 格式:DOCX 页数:6 大小:14.51KB
返回 下载 相关 举报
LINUX-Shell编程实验报告.docx_第1页
第1页 / 共6页
LINUX-Shell编程实验报告.docx_第2页
第2页 / 共6页
LINUX-Shell编程实验报告.docx_第3页
第3页 / 共6页
LINUX-Shell编程实验报告.docx_第4页
第4页 / 共6页
亲,该文档总共6页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《LINUX-Shell编程实验报告.docx》由会员分享,可在线阅读,更多相关《LINUX-Shell编程实验报告.docx(6页珍藏版)》请在三一文库上搜索。

1、LINUX-Shell编程实验报告LINUX管理与应用课程实验报告一、实验过程1. 编写一个简单的回显用户名的shell程序2. 使用if-then语句创建简单的shell程序3. 使用if-then-else语句创建一个根据输入的分数判断是否及格的shell程序4. 使用for语句创建简单的shell程序5. 使用while语句创建一个计算1-5的平方的shell程序6. 用shell设计一个模拟考勤程序二、实验结果1.编写一个简单的回显用户名的shell程序#vi dat#!/bin/bash#echo Mr.$USER,Today is:echo dateecho Wish you a

2、lucky day!#chmod +x dat#./dat2. 使用if-then语句创建简单的shell程序#vi bbbb#!/bin/bash#echo -n Do you want to continue: Y or Nread ANSWERif $ANSWER = N -o $ANSWER = n thenecho your answer is quit!fi#chmod +x bbbb#./bbbb3. 使用if-then-else语句创建一个根据输入的分数判断是否及格的shell程序#vi ak#!/bin/bash#echo -n please input a score:re

3、ad SCOREecho You input Score is $SCOREif $SCORE -ge 60 ;thenecho -n Congratulation!You Pass the examination.elseecho -n Sorry!You Fail the examination!fiecho -n press any key to continue!read $GOOUT#chmod +x ak#./ak4. 使用for语句创建简单的shell程序#vi mm#!/bin/bash#for ab in 1 2 3 4doecho $abdone#chmod +x mm#.

4、/mm5. 使用while语句创建一个计算1-5的平方的shell程序#vi zx#!/bin/bash#int=1while $int -le 5 dosq=expr $int * $intecho $sqint=expr $int + 1doneecho Job completed#chmod +x zx#./zx6. 用shell设计一个模拟考勤程序,实现如下功能选择界面:1:上班签到2:下班签出3:缺勤信息查阅# vi testshell#! /bin/bash#exsig=0while true; doecho echo -欢迎使用本系统-echo 1. 上班签到done elsee

5、cho System Error:userinfo.dat does not exist! fiif test $fname != $namethenecho 不存在该用户!elif test $fpassword != $passwordthenecho 密码不正确!elseecho 你的记录:echo -cat -b /home/user/check.dat|grep $nameecho -fi;4)echo 欢迎你的使用,再见!exsig=1;*)echo 请输入合法的选项!;esacif test $exsig = 1thenbreakfidone七试验运行结果:#chmod +x testshell#./testshell三、实验分析通过这次实验,我懂得了定义SHELL程序设计中的变量,掌握了SHELL程序中LINUX 基本命令的使用,理解了Shell程序的设计方法,并且熟悉了Shell程序编辑、运行、调试方法与过程。这为我日后继续深入学习Linux课程打下基础。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1