LinuxShell脚本编程实例.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:6 大小:29KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

LinuxShell脚本编程实例.doc

LinuxShell脚本编程实例.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

#!/bin/shecho"Currentcommandis$0"echo"Thefirstparameteris$1"echo"Thesecondparameteris$2"echo"Thethirdparameteris$3"echo"Totalofparametersif$#"echo"CurrentPIDis$$"#!/bin/bashtimes=0until["$times"=3];doecho"Ilovelinux."sleep2times=`expr$times+1`done#!/bin/bash#menushellscript.samli2004.4.19untilecho"ListDirectory..........1"echo"ChangeDirectory........2"echo"EditFile...............3"echo"RemoveFile.............4"echo"ExitMenu...............5"readchoicetest$choice=5docase$choicein1)ls;;2)echo"entertargetdirectory:"readdircd$dir;;3)echo"enterfilename:"readfilevi$file;;4)echo"enterfilename:"readfilerm$file;;5)echo"Goodbye";;*)echo"illegaloption,pleaseinputagain."esacdone#!/bin/shvar1="abcdefg"echo$var1var2=1234echo"Thevalueofvar2is$var2"echo$HOMEecho$PATHecho$PWD#!/bin/shnum=0while[$num-le10]donum=`expr$num+1`if[$num-eq5]thencontinuefisquare=`expr$num\*$num`echo$squaredone#!/bin/bash#Gnubashversions2.x#ThePartyProgram--Invitationstofriendsfromthe#"guest"fileguestfile=./guests#~/shell/guestsif[[!-e"$guestfile"]]thenprintf"${guestfile##*/}non-existent"exit1fiexportPLACE="Sarotini's"((Time=$(date+%H)+1))setcheesecrackersshrimpdrinks"hotdogs"sandwichesforpersonin$(cat$guestfile)doif[[$person=root]]thencontinueelse#Startofheredocumentmail-v-s"Party"$personHi${person}!Pleasejoinmeat$PLACEforaparty!Meetmeat$Timeo'clock.I'llbringtheicecream.Wouldyoupleasebring$1andanythingelseyouwouldliketoeat?Letmeknowifyoucan'tmakeit.Hopetoseeyousoon.Yourpal,ellie@$(hostname)FINISshiftif(($#==0))thensetcheesecrackersshrimpdrinks"hotdogs"sandwichesfifidoneprintf"Bye..."#!/bin/sh#StandardAT&TBourneShell#ThePartyProgram--Invitationstofriendsfromthe#"guest"fileguestfile=./guests#/home/ellie/shell/guestsif[!-f"$guestfile"]thenecho"慴asename$guestfile?non-existent"exit1fiPLACE="Sarotini's"exportPLACETime=`date+%H`Time=`expr$Time+1`setcheesecrackersshrimpdrinks"hotdogs"sandwichesforpersonin$(cat$guestfile)doif[$person=root]]thencontinueelse#Startofheredocumentmail-v-s"Party"$personHi$person!Pleasejoin