




已阅读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年智能电网建设与新能源并网合同执行标准规范
- 2025年城市绿化工程生态保护责任承包合同
- 2025单招金融学面试题及答案
- 2025年创新型企业知识产权全方位保护及商业模式创新合作协议
- 2025年度新能源汽车购置尾款融资租赁合同
- 2025年度全国跨区域医疗专家交流与协作聘用合同
- 2025年航空器抵押贷款合同:公务机贷款协议
- O2O智能家居产品销售及售后服务合作协议范本
- 2025年新型社区公共浴池运营维护与管理服务协议
- 2025年城市综合体停车场美化升级与维护保养服务协议
- 人流术后的护理及健康宣教
- 兵团两委考试试题及答案
- JG/T 2-2018钢制板型散热器
- DB31/T 636.1-2018会议经营与服务规范第1部分:会议服务机构等级划分与评定
- 种植牙和解协议书
- 夫妻房屋加名协议书
- 《大脑中动脉解剖结构》课件
- z08小升初数学试卷及答案
- 智慧水务数字化供水平台建设方案
- 2025-2030焦炭行业市场深度调研及发展规划与投资前景研究报告
- 旧房整修工程施工组织设计
评论
0/150
提交评论