已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
01.sh#!/bin/bash#program #this program shows Hello everyone !welcome to the world of shell script in your screen#History:# 2013/03/25 cc first releaseecho Hello everyone!echo welcome to the world of the shell script!02.sh#!/bin/bash#program #this program shows Hello everyone !welcome to the world of shell script in your screen#History:# 2013/03/25 cc first releaseread -p please enter your name: nameecho Hello $name,echo welcome to the world of shell script!03.sh#!/bin/bash#program:#let user input a filename,the program will search the filename #1)exist? 2)file or directory? 3)file permissions#让用户输入文件名,并且判断用户是否真的有输入字符串echo -e the program will show you that the filenames type and permission which you input.read -p input a filename:filenametest -z $filename & echo you must input a filename! & exit 0#判断文件是否存在,如果不存在则结束脚本test ! -e $filename & echo the file whose named $filename is not exit & exit 0#判断是否是普通文件,如果不是则结束脚本test ! -f $filename & echo the filename is not a regular file & exit0#文件存在且为普通文件,则开始判断文件的属性perm=test -r $filename & perm=$perm&readabletest -w $filename & perm=$perm&writabletest -x $filename & perm=$perm&executable#输出判断信息echo the regular &filenames permission is:$perm.04.sh#!/bin/bash#program:#this program show users choice echo if you want to continue ,please input Yecho if you want to interruput,Please input Nread -p please input your choice: choice $choice = Y -o $choice = y & echo ok ,continue! & exit 0 $choice = N -o $choice = n & echo ok ,interrupt! & exit 0echo i dont know what your choice is & exit 005.sh#!/bin/bash#program#this program will tell you the default variables used in scriptecho the script name is $0echo the first parameter is $1echo the second parameter is $2echo the third parameter is $3echo total parameter number is $#echo the whole parameter is $06.sh#!/bin/bash#program#this program show users choice echo if you want to continue ,please input Yecho if you want to interruput,Please input Nread -p please input your choice: choiceif $choice = Y -o $choice = y ;then echo ok ,continue! exit 0fiif $choice = N -o $choice = n ; thenecho ok ,interrupt! exit 0fiecho i dont know what your choice is exit 007.sh#!/bin/bash#program#this program show users choice echo if you want to continue ,please input Yecho if you want to interruput,Please input Nread -p please input your choice: choiceif $choice = Y -o $choice = y ;then echo ok ,continue! exit 0elif $choice = N -o $choice = n ; thenecho ok ,interrupt! exit 0elseecho i dont know what your choice is exit 0fi08.sh#!/bin/bash#program#show your choice with English(use if.then)echo which one is your favoriteecho 1.appleecho 2.bananaecho 3.orangeread -p please enter your choice (1-3): choiceif $choice = 1 ; thenecho your choice is APPLE!elif $choice = 2 ; thenecho your choice is BANANA!elif $choice = 3 ; thenecho your choice is ORANGE!else echo you must input a int from 1 to 3!fi09.sh#!/bin/bash#program#the program will test the character type you enteredread -p press some key then press return : KEYcase $KEY ina-z|A-Zecho its a letter.;echo its a digit.;*)echo its function Keys,Spacebar or other keys.esac10.sh#!/bin/bash#program:#the program executes the program you specifiedcase $1 instart| end)echo stop something;*)echo Ignorant;esac11.sh#!/bin/bash#program# this program will detect what operating system you useSYSTEM=uname -scase $SYSTEM inLinux)echo my system is Linuxecho do Linux stuff here.;FreeBSD)echo my system is FreeBSD echo do FreeBSD stuff here.*)echo Unknown system : $SYSTEMecho i dont know what to do .;esac12.sh#!/bin/bash#filename ;平均值function increment()avg=$($1+$2)/2)echo 在函数输出的值为 : $avgincrement $1 $213.sh#!/bin/bash#program:# plus int from 1 to 100s=0i=1while $1 -Lt 101 dos=$($s+$i)i=$($i+1)echo $i is plused to sdoneecho the result of 1+2+3+.+100 is $s14.sh#!/bin/bash#program:# plus int from 1 to 100s=0i=1until $1 -gt 101 dos=$($s+$i)i=$($i+1)echo $i is plused to sdoneecho the result of 1+2+3+.+100 is $s!15.sh#!/bin/bash#program# this program will tell us the use of mathematical expressionsecho please input 2 numbers,i will cross theyread -p first number: n1read p- second number: n2total1=$($n1*$n2)declare -i total2=$n1*$n2echo the number $n1*n2=$total1 echo the number $n1*n2=$total216.sh#!/bin/bash#progr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年高危儿管理试卷及答案
- 怀化市农村信用社联合社秋季校园招聘笔试备考题库(浓缩500题)附答案详解(研优卷)
- 临沧市农村信用社联合社秋季校园招聘笔试备考题库(浓缩500题)有完整答案详解
- 2025年全国特种设备检验检测人员考试电梯检验员复习题库及答案
- 丰都县农村信用社联合社秋季校园招聘笔试备考题库(浓缩500题)及完整答案详解1套
- 2025年飞行员执照考试《商用驾驶员(飞机)》冲刺试题及答案一
- 2025年云南省特种作人员取证培训以及特种设备作业人员取证培训考试煤矿瓦斯抽采作业复习题及答案
- 2026年汕尾市农村信用社联合社秋季校园招聘笔试备考题库(浓缩500题)及答案详解(考点梳理)
- 2025年福建中级职称教育教学能力水平考试(道德与法治)(初中)综合练习题及答案
- 2025年全国特种设备检验检测人员专业培训考试起重机械检验师复习题及答案
- 2025年10月自考00402学前教育史押题及答案
- 清新福建魅力八闽课件
- 2025年中国商用和家用净水系统行业市场全景分析及前景机遇研判报告
- 胆囊结石伴胆囊炎护理
- 纤支镜吸痰护理规范
- 测绘工程项目实施方案书模板
- 农村教育资源优化配置-洞察及研究
- 电气岗前安全培训教学课件
- (正式版)DB61∕T 5078-2023 《体育建筑工艺设计标准》
- 国家能源集团笔试试题及答案
- 安全体验馆培训内容课件
评论
0/150
提交评论