操作系统实验报告1
更新时间:2023-04-07 14:46:01 阅读量: 教育文库 文档下载
- 操作系统推荐度:
- 相关推荐
操作系统实验报告 1
《计算机操作系统》实验报告实验题目:进程控制
姓名:学号:实验日期:
SHELL编程实验:
实验目的:
掌握vi的三种工作方式,熟悉vi编辑程序的使用。
学习Shell程序设计方法。掌握编程要领。
实验内容:
学习使用vi编辑程序。
编写Shell程序。
将程序文件设置为可执行文件(用chm od命令)。
在命令行方式中运行Shell程序。
操作过程:
操作系统实验报告 1
用vi编写第四部分“ Shell程序设计”中的例1 (假设文件名为myprogl.h)
操作系统实验报告 1
Kieuqa>i ocainosr
File Edit View Tferminai [kieu@loc atho st ~]$ vi my p ro g L .h
[kleu^loc alho st —]i c at myp rog1,h #Name display p rog ram
IT [ $# = O ]
then
ec ho * Name not P rovided"
eVse
echo " You r name 1 s *' $L
fl
[kieu@loc atho st ~]$ ./myp rog L . h Th eodo re
You r name a s Theodo re
[kieu^localhost ~]车 ■
进一步修改例1程序,要求显示参数个数,程序名字,并逐个显 示参数。
[kieu^Localhost —]事 vi myp rog L .h [kieu @Loc alh os t —]$ c at myp rog L.h #1Mame di splay p rog ram if [车# = o ] then echo " You r shell p rog ram name 1 s *' $o et se ec ho " You r pa ramete r nu mbe r is 11 勒# T± [kieu@Toc^lh ost 一]车./myp rog 1,h You r sheXL p rog ram n ame 1s ./myp rog L ? h [kieu @Localhost ~]乍 ./myp r o g1,h kieu d i en You r pa ramete r nuimbe r is 2 [kieu @l_oc aThost ~]峯■
修改例1程序,用read 命令接受键盘输入。若没输入字符显示第 一种显示,否则第二中显示。 [kieu@locathost ~]$ [kieu^loc aLho st —]t Name nor P
rovided
c hmo
d 755 myp rog L. h ./myp
rog L.h
操作系统实验报告 1
用vi编写第四部分“ Shell程序设计”中的例2 (假设文件名为st.h ),例3 (假设文件名为compare2.h)
read ch
if
【th
en
-z tch 1
else
echo "Name not provided
fi
echo "You r name is " $th
[kieu^localhost ./myp rogl.h kieu
You r name is kieu
[kied^localhos t “]$ ./myp rogLh
Name not provided
[kieu^localhost T* |
[kieu^localhost ~]f vi mypr ogl.h
[kieu^localhost ~ji cat myp roql,h #Name
display p rog ram
操作系统实验报告 1
.. oca lh OS
file £dit 里 iew Jerminal F|elp
then echo 11 cppdi r has execute pe rmi ssione"
el se
echo "cppdi r does not have execute pe rmissione f i
f kjeu@loc alhost t -/compa re2.h
c ppdi r i s a di rec to ry
filea 1s a regula r file
filea has read pe rmissione
filea dose not have wriet pe rmissione
cppdi r h a5 exec u te pe rmissione
修改例2 (假设文件名为st.h )程序使在程序运行中能随机输入 字符串,然后进行字符串比较
echo "st ring 1 not
equal to st ring2H fi
■if [ t ring L ]
then echo " st ring 1 i s else not emp 七y" echo "st ring 1 is f i if ( - n st nng2 )
empty
亡亡ho "st ring2 has el se
a length g reate r than ze ro echo " s t irzng2 has f i a length equal to zero 11
[kleu@l DC alhost ~]$ ./st kieu kieu h
st ringl equ al to st ring2 st ringl is not empty el se
st ring2 has a length g reate r th an ze ro [kj.eu01ocalhost -11 II el &e fi
if [ the n
else fi if ( the echo "filea
has read permissione" echo "f ilea dose
rot have read pe rmisaione" w filea ] echo ■fil ea has 1 w rite pe rmi ssione" echo "files
dose not have wriet pe rmis sione p x 匚ppdi r ]
[kzeu^localhost -]慕 cat st . h read strlngl read st ring2 if [ tst ring 1 = $st ring2 ] then echo "st ring L equal to s t ring2-
操作系统实验报告 1
修改例3 (假设文件名为compare2.h )程序使在程序运行中能随 机输入文件名,然后进行文件属性判断。
[kieu^localhost ~]t cat compare2 + h read filename
if [ -f filename ]
then echo iLename " is a reguLar file n el se
echo tfilename " ia not a regula r file'1 f i
if [ -r filename ]
then
has read pe rmissione" dose not have read pe rmissione* has write pe rmi5sione " dose not have wriet permissione
[kieu^tocalhost ~]t ./compa re2 r h st . h
st.h 1s a regula r file
st > h has read pe rmissione
st .h has write pe rmissione
[kieu^localhost |
用vi 编写第四部分“ Shell 程序设计”中的例9 (假设文件名为 fun ) echo tfiLename eL
se
echo ILename f i if [ -w filename ] then
echo tfilename
el se
echo liename fl
-rwx r- x r- x . d rwx r- x r- x. d rwx r- x r- x . L kieu 2 kieu 2 kieu kieu 341 kieu 4096 kieu 4096 2009-11-04 2G09-1G-3L 2G09 ?1G ■3L 12: G6 17: 25 reaplates 17:25 Videos
操作系统实验报告 1
区' kieu^lccalhost :^ 命 File Edit View Jerminal 旦 elp [kieu^localhast T$ cat fun.h
displaymon th (){ case in
01
02
esac
}
displaymonth 8 displaymanth 12
[kieu@local.hosr . /fun . h month is Augu st mon th is Decembe r
[kieu@l_ocal.h0st | 编程,在屏幕上显示用户主目录名(HOM )命令搜索路径(PATH , 并显示由置参数指定的文件的类型和操作权限。
结果:
叫 试一试vi 的三种工作方式个用在什么时候?用什么命令进入 插入方
式?怎么退出插入方式?文件怎么存盘注意存盘后的 提示信息。
基本上vi 可以分为三种状态,分别是命令模式(comma nd
mode 、插入模式(In sert mode 和未行模式(last li ne mode , 各模式的功能区分如下:1) echo "month is Janua ry ";,
2) echo "man th is Februa ry";;
3) echo "month is Ma rc h ";;
4)
echo "month is Ap riV"::
5) echo "month is May";;
6) echo "month is June"\ \
7) echo "month is July";;
3) echo "month is August "* *
9} echo "month is Scptembe r";; 11) echo "month is November";; 012
12) echo "month is December";; *) echo
"Invalid parameteL ;;
10) echo "month is October";;
345678911
操作系统实验报告 1
1)命令行模式command mod)e :控制屏幕光标的移动,
字符、字或行的删除,移动复制某区段及进入Insert mode下, 或者到last line mode 。
2)插入模式( Insert mode ) :只有在Insert mode 下,才
可以做文字输入,按「ESC键可回到命令行模式。
3)未行模式( last line mode) :将文件保存或退出vi ,
也可以设置编辑环境,如寻找字符串、列出行号……等。
不过一般我们在使用时把vi 简化成两个模式,就是将未行模式( last line mode )也算入命令行模式command mod)e 。
体会:
熟悉了vi 三种工作方式,学会了创建和执行shell 程序。
正在阅读:
操作系统实验报告104-07
36#设计说明 - 图文01-11
精品-2019年春七年级数学下册第6章数据与统计图表6.1第1课时数据的整理练习新版浙教版12-13
张爱玲作品分析10-04
心理学打印版03-29
论老子的管理思想10-04
“十三五”规划重点-氢化羊毛脂项目建议书(立项报告)12-24
珠海成人教育《财务分析》复习题 - 图文10-02
大学管理制度01-09
上海海事大学金工实习报告答案(完整版)06-19
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 操作系统
- 实验
- 报告
- 计算机控制技术习题参考答案完整版
- 可编程控制器及应用实验报告
- 贝壳加盟经纪人成长体系培训《解读ACN规则》测试题B卷
- 第一医院青年文明号领导小组职责
- 2022年舞蹈系论文开题报告
- 法语学习自测题325期
- 2022届高考作文预测:纯白、漂亮的羽毛(附范文)-作文教学
- 2022年贵州师范大学外国语学院448汉语写作与百科知识
- 防突细则题库(100问)
- 技术支持的方法指导 《通用技术》课堂教学反思
- 申论必背范文【经典】全30篇
- 九年级数学下册26弧长与扇形面积解读圆弧长公式的导出及应用素材
- 三年级语文《元日》微课设计
- 最新人教版小学二年级数学下册第二单元教案.doc
- 建筑施工企业安全培训教材节选
- 国内外乙烯基酯树脂牌号及各树脂性能
- (完整版)七年级英语下册第二单元知识点详细总结(译林版)(最新整
- 基础英语课后习题答案
- 【完整版】2022-2025年中国蚝油行业技术发展趋势研究报告
- 小学一年级最新班会课“保护视力,从我做起”