文档介绍:LINUX-Shell编程实验报告《LINUX管理与应用》课程实验报告≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡实验内容和目的实验目的:理解Shell程序的设计方法;熟悉Shell程序编辑、运行、调试方法与过程。实验内容:(1)Shell简单编程用户名回显程序;if-then、if-then-else语句使用;for语句、while语句使用(2)较复杂的考勤模拟shell程序设计实验环境微机、WINDOWSXP、QUICKLINUX、VMWARE虚拟机软件实验重点及难点实验重点:SHELL编辑、运行过程;SHELL变量的使用,分支语句的设计,循环语句的设计实验难点:SHELL语句的使用方法实验过程(实验过程、实验结果及实验分析)一、--then--、#vidat#!/bin/bash#filename:datecho"Mr.$USER,Todayis:"echo`date`echoWishyoualuckyday!#chmod+xdat#./-then语句创建简单的shell程序#vibbbb#!/bin/bash#filename:bbbbecho-n"Doyouwanttocontinue:YorN"readANSWERif[$ANSWER=N-o$ANSWER=n]thenecho"youranswerisquit!"fi#chmod+xbbbb#./-then-else语句创建一个根据输入的分数判断是否及格的shell程序#viak#!/bin/bash#filename:akecho-n"pleaseinputascore:"readSCOREecho"YouinputScoreis$SCORE"if[$SCORE-ge60];thenecho-n"Congratulation!YouPasstheexamination."elseecho-n"Sorry!YouFailtheexamination!"fiecho-n"pressanykeytocontinue!"read$GOOUT#chmod+xak#./#vimm#!/bin/bash#filename:mmforabin1234doecho$abdone#chmod+xmm#./-5的平方的shell程序#vizx#!/bin/bash#filename:zxint=1while[$int-le5]dosq=`expr$int\*$int`echo$sqint=`expr$int+1`doneecho"pleted"#chmod+xzx#./,实现如下功能选择界面:1:上班签到2:下班签出3:缺勤信息查阅#vitestshell#!/bin/bash#filename:shelltestexsig=0whiletrue;doecho""echo"----欢迎使用本系统----"echo""echo""echo""echo""echo"----------------------"echo""echo"请输入你的选项:"readchoicecase$choicein1)echo"请输入你的名字:"readnameecho"请输入你的密码:"readpasswordiftest-r/home/user/"$fname"echo"$fpassword"iftest"$fname"="$name"thenbreakfidone</home/user/:!fiiftest"$fname"!="$name"thenecho"不存在该用户!"eliftest"$fpassword"!="$password"thenecho"密码不正确!"elsehour=`date+%H`iftest"$hour"-gt8thenecho"你迟到了!"echo"$name上班迟到---日