已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 肿瘤个体化治疗策略与临床实践分享
- 县域医共体基层服务能力提升方案
- 双抗个体化治疗中的个体化治疗识别处理策略
- 2026年一级建造师之一建铁路工程实务考试题库300道附完整答案(易错题)
- 2026年一级注册建筑师之建筑经济、施工与设计业务管理考试题库300道含答案【新】
- 2025河南郑州牟中发展投资有限公司招聘国企正式人员4人模拟试卷附答案
- 2025汶川县欣禹林业有限责任公司工作人员招聘25人考前自测高频考点模拟试题附答案
- 2025湖南衡阳市常宁市审计局审计事务中心选调3人备考题库附答案
- 2026年一级建造师之一建矿业工程实务考试题库300道含答案(黄金题型)
- 2025甘肃甘南州舟曲县选调8人备考题库附答案
- 电商直播女装带货脚本话术模板
- 2025年高中地理学业水平合格考试知识点(复习必背)
- 去毛刺培训知识课件
- 通讯机房安全管理培训课件
- 新解读《DA-T 42-2009企业档案工作规范》
- 《PLC电气控制技术》课件(共九章)
- 实施指南(2025)《JC-T 2822-2024 水泥替代原料》
- 2025年通榆县事业单位面向社会公开招聘工作人员及公开招聘基层治理专干(19人)考试参考试题及答案解析
- (已压缩)国民体质测定标准(2023年修订)
- (正式版)DB14∕T 3556-2025 《食品生产企业信用风险分级指南》
- EP28-A3c 临床实验室中参考区间的定义、建立和验证(中文下载)
评论
0/150
提交评论