欢迎来到天天文库
浏览记录
ID:20412794
大小:89.61 KB
页数:9页
时间:2018-10-12
《genesis2000脚本编写常用命令解析》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Genesis2000脚本编写常用命令解析1.switch的用法,注意每一个case必须耍以breaksw结尾否则会继续执行下一个case的命令(1)另外,$<的意思是取得使用奍的standinput(2)echo若加上-n的选项,则游标会停沼在该行最后echo-n"Inputonecolor:•’setSTOPLIGHT=$2、t$STOPLIGHT"endsw2.利用set来取得变数,setABC=’’IamABCn也以利用'command'來取得命令且外,case也可以川万川字元*來代替setVER='uname-r'switch($VER)case5.5:echo"runthesetupof$VER"breakswcase5.3:echo"runthesetupof$VER"breakswcase5.*:echo"like5.x"breakswcase4.*:echo"like4.x"breakswdefault:echoHnoidea’.endsw1.if的语法,比较数字setn1=3、:1setn2=:2if($n1=echo==$n2)then"$n1Equal$n2"elseecho"$n1NotEqual$n2"endif2.if的语法,比较字串setn1=:abcdefsetn2=:abcdeif($n1=echo==$n2)then"$n1Equal$n2"elseecho"$n1NotEqual$n2"endif3.if的语法,比较相似的字串setn1=:abcdefsetn2=:abcdeif($n1=echo=〜$n2)then"$n1Like$n2"elseechoH$n1NotLike$n2nendif4.if的语法,比较数字的4、大小setn1=1setn2=2if($n1>$n2)thenecho"$n1>$n2"elseecho"$n1<$n2"endif1.每分钟执行一次的程式林mm等于当天时间的【分钟】数setmm='date5、cut-d'1446、cut-d:-f2if(-r$0.out)thenrm$0.outtouch$0.outelsetouch$0.outendifwhile($mm<=16)setmm='date7、cut-cf•448、cut-d:42echo"$mmnowis'date'”sleep60#echo"$mmnowis'date'”>>$0.outendecho"9、Over”〉>$0.out2.—个回圈的范例,井.FL利川expr去作加的动作I叫圈的语法如下:foreachnumber(123)echo$numberendsetcounter=0while($counter<=10)echo"sleepingfor5seconds•’sleep5counter='expr$counter+1end1.设定一个用当天月份与口期作为档案名称的程式如今天是10/02,则$prefix会等于该程式+1002date.csh1002setprefix='basename$0''date•+%m%cf'echo$0echo$prefix2.10、移除在foreach回圈内指定的档案内的font字串foreachfile([b,e,g,h,s]*.html)echo-n"Processing$file,removethelinenumberxgrep-nfont$file'林Slog表示这个$file有儿个font字串setlog="grep-cfont$file"if($log=='0*)thenecho’•,pass$file"else#先找出该档案的第一次出现font的行数,如果3,则$cmd=3dsetcmd='grep-nfont$file11、cut-d:-f112、head-1'd#利用sed去执行删除的13、动作,并把结果输Hi到${file}1sed$cmd$file>${file}1林如果${file}1没有资料,则passingif(-z${file}1)thenecho••,${file}1iszero"elsecp${file}1$filerm{$file}1echo••,$fileremoveok11endifendifend林后來看过sed的更进一步用法,发现先前写的太笨了,试试这个#sed/font/d$file>${file}1林一次OK,我是大笨蛋11.功能:将指定的档案中,出现第一次【回】的那一行,加上xxxx
2、t$STOPLIGHT"endsw2.利用set来取得变数,setABC=’’IamABCn也以利用'command'來取得命令且外,case也可以川万川字元*來代替setVER='uname-r'switch($VER)case5.5:echo"runthesetupof$VER"breakswcase5.3:echo"runthesetupof$VER"breakswcase5.*:echo"like5.x"breakswcase4.*:echo"like4.x"breakswdefault:echoHnoidea’.endsw1.if的语法,比较数字setn1=
3、:1setn2=:2if($n1=echo==$n2)then"$n1Equal$n2"elseecho"$n1NotEqual$n2"endif2.if的语法,比较字串setn1=:abcdefsetn2=:abcdeif($n1=echo==$n2)then"$n1Equal$n2"elseecho"$n1NotEqual$n2"endif3.if的语法,比较相似的字串setn1=:abcdefsetn2=:abcdeif($n1=echo=〜$n2)then"$n1Like$n2"elseechoH$n1NotLike$n2nendif4.if的语法,比较数字的
4、大小setn1=1setn2=2if($n1>$n2)thenecho"$n1>$n2"elseecho"$n1<$n2"endif1.每分钟执行一次的程式林mm等于当天时间的【分钟】数setmm='date
5、cut-d'144
6、cut-d:-f2if(-r$0.out)thenrm$0.outtouch$0.outelsetouch$0.outendifwhile($mm<=16)setmm='date
7、cut-cf•44
8、cut-d:42echo"$mmnowis'date'”sleep60#echo"$mmnowis'date'”>>$0.outendecho"
9、Over”〉>$0.out2.—个回圈的范例,井.FL利川expr去作加的动作I叫圈的语法如下:foreachnumber(123)echo$numberendsetcounter=0while($counter<=10)echo"sleepingfor5seconds•’sleep5counter='expr$counter+1end1.设定一个用当天月份与口期作为档案名称的程式如今天是10/02,则$prefix会等于该程式+1002date.csh1002setprefix='basename$0''date•+%m%cf'echo$0echo$prefix2.
10、移除在foreach回圈内指定的档案内的font字串foreachfile([b,e,g,h,s]*.html)echo-n"Processing$file,removethelinenumberxgrep-nfont$file'林Slog表示这个$file有儿个font字串setlog="grep-cfont$file"if($log=='0*)thenecho’•,pass$file"else#先找出该档案的第一次出现font的行数,如果3,则$cmd=3dsetcmd='grep-nfont$file
11、cut-d:-f1
12、head-1'd#利用sed去执行删除的
13、动作,并把结果输Hi到${file}1sed$cmd$file>${file}1林如果${file}1没有资料,则passingif(-z${file}1)thenecho••,${file}1iszero"elsecp${file}1$filerm{$file}1echo••,$fileremoveok11endifendifend林后來看过sed的更进一步用法,发现先前写的太笨了,试试这个#sed/font/d$file>${file}1林一次OK,我是大笨蛋11.功能:将指定的档案中,出现第一次【回】的那一行,加上
此文档下载收益归作者所有