- 1、本文档共8页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
LINUX–Shell编程实验报告
《LINUX管理与应用》课程实验报告
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
实验实验实验实验环境实验重点及难点实验重点实验难点#!/bin/bash
#filename:dat
echo Mr.$USER,Today is:
echo `date`
echo Wish you a lucky day!
#chmod +x dat
#./dat
2. 使用if-then语句创建简单的shell程序
#vi bbbb
#!/bin/bash
#filename:bbbb
echo -n Do you want to continue: Y or N
read ANSWER
if [ $ANSWER = N -o $ANSWER = n ]
then
echo your answer is quit!
fi
#chmod +x bbbb
#./bbbb
3. 使用if-then-else语句创建一个根据输入的分数判断是否及格的shell程序
#vi ak
#!/bin/bash
#filename:ak
echo -n please input a score:
read SCORE
echo You input Score is $SCORE
if [ $SCORE -ge 60 ];
then
echo -n Congratulation!You Pass the examination.
else
echo -n Sorry!You Fail the examination!
fi
echo -n press any key to continue!
read $GOOUT
#chmod +x ak
#./ak
4. 使用for语句创建简单的shell程序
#vi mm
#!/bin/bash
#filename:mm
for ab in 1 2 3 4
do
echo $ab
done
#chmod +x mm
#./mm
5. 使用while语句创建一个计算1-5的平方的shell程序
#vi zx
#!/bin/bash
#filename:zx
int=1
while [ $int -le 5 ]
do
sq=`expr $int \* $int`
echo $sq
int=`expr $int + 1`
done
echo Job completed
#chmod +x zx
#./zx
6. 用shell设计一个模拟考勤程序,实现如下功能选择界面:
1:上班签到2:下班签出3:缺勤信息查阅
# vi testshell
#! /bin/bash
#filename:shelltest
exsig=0
while true; do
echo
echo ----欢迎使用本系统----
echo 1. 上班签到
echo 2. 下班签出
echo 3. 考勤信息查询
echo 4. 退出系统
echo ----------------------
echo
echo 请输入你的选项:
read choice
case $choice in
1)echo 请输入你的名字:
read name
echo 请输入你的密码:
read password
if test -r /home/user/userinfo.dat
then
while read fname fpassword
do
echo $fname
echo $fpassword
if test $fname = $name
then
break
fi
done /home/user/userinfo.dat
else
echo System Error:userinfo.dat does not exist!
fi
if test $fname != $name
then
echo 不存在该用户!
elif test $fpassword != $password
then
echo 密码不正确!
else
hour=`date +%
文档评论(0)