《linux的shell脚本实验报告》由会员分享,可在线阅读,更多相关《linux的shell脚本实验报告(7页珍藏版)》请在人人文库网上搜索。
1、第二次实验内容一、实验名称:Linux下shell编程二、实验类型:设计三、实验目的:1 熟悉Linux的shell几种变量使用2 熟练掌握Linux的shell编程几种结构3 熟练掌握Linux下shell脚本的编写四、实验准备参考教材,课件第7章内容及笔记。要求实验内容全部写到实验报告上(B5纸)。五、实验内容1. 练习使用shell四种变量,参考课件例题。用户自定义变量,环境变量,位置变量,特殊变量这四种变量类型的使用,书中有例题。2. 调试课件所有shell脚本的例题。3. 编写如下脚本:l 编写脚本if1,测试其功能。 echo -n word 1: read word1echo -。
2、n word 2: read word2if test $word1 = $word2thenecho Matchfiecho End of program.l 编写脚本chkargs,测试其功能if test $# -eq 0thenecho You must supply at least one argument.exit 1fiecho Program running.l 编写脚本if2,测试其功能if test $# -eq 0thenecho You must supply at least one argument.exit 1fiif test -f $1thenecho $1。
3、 is a regular file in the working directoryelseecho $1 is NOT a regular file in the working directoryfil 编写脚本if3,测试其功能echo -n word 1: read