欢迎来到课桌文档! | 帮助中心 课桌文档-建筑工程资料库
课桌文档
全部分类
  • 党建之窗>
  • 感悟体会>
  • 百家争鸣>
  • 教育整顿>
  • 文笔提升>
  • 热门分类>
  • 计划总结>
  • 致辞演讲>
  • 在线阅读>
  • ImageVerifierCode 换一换
    首页 课桌文档 > 资源分类 > DOCX文档下载  

    奥宝gensis脚本培训(英文版).docx

    • 资源ID:908765       资源大小:122.30KB        全文页数:68页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    奥宝gensis脚本培训(英文版).docx

    ProgramminginCshellThroughtheDemoandTraiCentre,Orbotechiscommittedtoofferingitscustomersthehighestqualityprofessionaltraining,whichprovidesthemostefficientandeconomicalsolutionstothechallengesofthePrintedCircuitBoardIndustry.SouthernChinaCommittedtoExcellence4B-4C,BlockC1ElectronicsScience&TechnologyBldg.No.2070ShennanZhongRoadShenzhen518031Tel:(86)7553287800Fax:(86)7553287801DemozTrainingCentreSouthernChinaOrtxitechTechnology(Shenzhen)CompanyLtd.No.107-113,Block5A,InternationalCommerceCenterNo.1001HonghuaRoad,FutianFreeTradeZoneGuangzhouOfficeRoom1006-7l10F,EastTowerTianheEntertainmentPlaza621TianheRoadGuangzhou510630Tel:(86)20-8757-4616Fax:(86)20-8757-4620Tel:(86)75535951303595137NorthernChinaCommittedtoExcellenceFax:(86)7553595135DemoZTrainingCentreNorthernChinaShanghaiOffice1F,278ZhuJiangRoad(N)KunshanDevelopmentZoneKunshan1F,278ZhuJiangRoad(N)KunshanDevelopmentZoneKunshanRoom243,XinMaoBuilding,2TaiZhongRoad(三)WaigaoqiaoFreeTradeZone,Shanghai200131Tel:(86)520-735-7745Fax:(86)520-735-8628Tel:(86)520-735-7745Fax:(86)520-735-8628Tel:(86)21-5048-0555*4202Fax:(86)21-5048-0555-4202Cshismorethanasimplecommandlineprocessor.Itisalsoaprogramminglanguage.Youcanwriteprograms(calledscripts)thatareexecutedbytheCShell.CONTENTSLCOmmandform琏音误!未定义书签。SingIeCOmmandlMUltiPleCommandS2COmmandGrOUPS3ConditionalCommandExecution4SUrnmary52IOredirectionandPiDeS£音误!未定义书签。OUtPUtRedireCtionlAPPendingC)UtPUt2RedireCtingErrorC)UtPUl3SePanltingStandardOUtPUtandErrOrOUtPUt4TheBUilt-inNoClObberVariable5RedireCtingInPUt6COrmeCtingCommands:PiPeS7RedirectingStandardErrorThroughPipes9SummarylO3fWenameexpansion错误!未定义书签。FiIeIameEXPanSiOnMetaCharaCterSlMatChingFiIenameStringCOmPonentS2MatChingWithCharaCterSCIaSSeS3DeDVrdFilenameS4EscapeMechanisms5Summary641variableslSettingVaVabIeSlUsingShellVariables2WordlistVariables3VaVableSUbStitUtiOn4ReIeaSiagVariabIeS5TeStingifVariablesaseSet6PalhnamCVariableS7COmmandSUbStitUliOn8QUotiOgVariableS9ShellPreDefinedVariableslOSummaryl15,scriptslShellScriptslShelISCriCtS-EXamDleS2TheFOrmatOfShenSCriDtS3COmmentSinSheIISCriCtS4TheEChoCOmmand5ReadingDatafromtheTelTnina16PassingParameterstoShellProcedures7UsingArgv8TheShiflCommandloTheConditionalSlatemenl11ACaUIiOnOnUndefInedVariabIeS14TheEXECommand155.13SUmmary166.ExpreSSiolIEVaIUatk)IllEXDreSSiOnevaluationArithmetiCC)PeratorS2ReIatiOnalOPeratOrS3LOgiCalODeraIorS4OPeratOrPreCedenCe5FileInquiryOperators7SUmmary97LuodsandSWitCheSlTheForeaChStatementlTheWhveStatement2TheSWitChStatement3TheBreak&ContinUeStatement6theGotoStatement7SUmmary81. COMMANDFORMS11SlNGLECOMMANDTHEFoRNTATFoRASlNGLECOMMAND%command_namearguments<RETURN>NoTES1. command_nameisasimplenameoranyvalidpathname.2. argumentsmaybeaflag,apathnameorsomeotherspecialstring.3. Spacesand/ortabsalwaysseparatearguments.4. A<RETURN>keystroketerminateseachcommandline.5. Youcanuse<RETURN>tocontinuealongcommandtothenextline.EXAMPLESToprintthefullpathnameofyourcurrentworkingdirectory:%pwdTotypethestring'Hello'onourterminal:%echoHelloTocreatetwonewdirectoriesinyourcurrentdirectory:%mkdirdir_ldir_2Tosearchthedirectoryhierarchystartingfromyourcurrentdirectoryforallthefilesnamed'test.dat,andtoprinttheirfullpathname:%find-nametest.dat-printNOTESIfyouliketogiveanargumentthathasablankinityoumustusequotesordoublequotes.EXAMPLES% prog 'New York' % prog "New Yorku % prog New Yorkoneargument=NewYorkoneargument=NewYorktwoarguments;First=New,Second=York1.2MULTIPLECOMMANDSTheCShellallowsustoconcatenateseveralcommandsonasingleinputline.Asemicolonisusedtoseparatetheindividualcommands.THEFoRMATFoRMULTIPLECOMMANDS%command;command_2;command_nEXAMPLESTomakeanewdirectoryandtomakethatdirectorythework_directory:%mkdirinformation;cdinformationGotoadirectoryandcompileaprogram,afterthatgototheroot:%cdsource;ccprogl.c;cd/NoTES TheC_Shellexecutescommand_1,Command_2,command_nsequentially. Eachcommandinthelistmayhavearguments. Usemultiplecommandswhenasetofcommandsformsalogicalgroup.1.3 COMMANDGROUPSTheCShellallowsustotreatagroupofcommandsasasinglecommandandtorunthecommandgroupinasub_shell,preservingtheparentshell'senvironment.THEFORMATFoRACOMMANDGROUP%(cmd_l;cmd_2;.;cmd_n)EXAMPLESToillustrateacommandgroupinaction,consider:%(cdc_progs;ccprogl.c)Thiscommand(1)changesdirectories;(2)runsacompile;andthen(3)automaticallyreturnstoourparentshellandouroriginaldirectory.1.4 CONDITIONALCOMMANDEXECUTIONManyUNIXcommandsreturnstatusinformation.THECONVENTIONONormal(successful)exit.non-OAcommanderroroccurred.EXAMPLESTochecktheerrorstatusofacommand,usetheCShellvariablestatus:%echo$status1Inthiscase,Sstatus=1meansthatthefileprogl.cdoesn'tmatchthepatterngarfield.NoTES ACShellvariableisreferencedbyprefixingadollarsign($)toitsname. grepreturnsOstatusifitfindsthespecifiedpattern.Ifgrepcan,tfindthepattern,itreturns1;ifitcan'taccessthefile(orothererror),itreturns2.Toexecutecmd_2onlyifcmd_lsucceeds,weusethelogicalconnectiveoroperator&&asfollows:%cmd_l&&cmd_2Similarly,Wecanusethelogicalconnectivetoexecutecmd_2onlyifcmd_lfailsasfollows:%cmd_lHcmd_2EXAMPLESHere,weusegreptosearchthefileforthestringG54.IfgrepfindsG54,itwillreturnastatusvalueofO(i.e.OK).Onlyinthiscasewillthefilebespooledtothelineprinter.%grepG54xl234.gbrif($status=1)echo,G54NOTFOUNDn1.5SUMMARY Commandsconsistofprogramnamesfollowedbyarguments(separatedbyspacesortabs). Manycommandsexpectspecialargumentscaseoptions,usuallyintroducedbythe,-,character. Mostotherargumentsarepathnames. Acommandlinemaycontainseveralrelaycommandsseparatedbysemicolons;thesecommandsexecutesequentially. Commandscanbealsoformedintogroups,enclosingtheminparentheses. Commandgroupsruninasub-shell,withoutdisturbingtheparentshell'sexistingenvironment. Commandsconnectedby&&orexecuteconditionally.TABLEOFCoMMANDFORMSCommandFormMeaning%cmd_nameargumentsSinglecommand%cmd_l;cmd_2Multiplecommand%(cmd_l;cmd_2)Commandgroup%cmd_l&&cmd_2Executecmd_2ifcmd_lsucceeds%cmd_lHcmd_2Executecmd_2ifcmd_lfails21OUTPuTREDHiECHONOutputredirectionletsussavecommandoutputinafileforlaterreferenceorforuseasinputtoanotherprogram.Theoutputthatnormallyappearsonourscreen(excludingerrormessages)iscalledstandardoutput(abbreviatedstdout).Wemayredirectstandardoutputtoafilebymeansofthe>symbol,asin:%command>fileNoTES Outputfromasinglecommandorfromacommandgroupmayberedirected. Thespacessurroundingthe>symbolareoptional. Iffiledoesnotexist,theCShellwillcreateit. Iffiledoesexist,itspreviouscontentswillbeoverwritten(destroyed).EXAMPLESToredirecttheoutputofthelistdirectory(Is)commandintofile.infb,wecanuse:THECOMMANDPutsadate-timestampintobeforethedirectoryinformation.Notethatomittingthecommandgroupparenthesesasin:SendstheoutputfromdatetotheterminalandtheresultsoftheIs-1commandtofile.infb.CAUTIONDonotusethesamefileasacommandlineargumentandalsoasthetargetofoutputredirection.EXAMPLESFirst,theCShellopensandtruncatesittoanullfile;thenitcatenates(nowanullfile)andinto.Thefinalresult:iscopiedto.Theoriginalcontentsofarelost.SettingtheCshellvariablenoclobberpreventsthiscommonerror.2.2APPENDINGOUTPUTWemayredirectstandardoutputtotheendofanexistingfilebymeansofthe»redirectionsymbol.Inthiscase,thepreviouscontentsofthedestinationfilewillnotbedestroyed.Ifthefiledoesnotexist,theCShellwillcreateit,justasinthecaseofthe>redirectionsymbol.THEGENERALCOMMANDFORMAT%command»fileEXAMPLESNOTESEachtimetheabovesequenceofthreecommandsisexecuted,additionaloutputwillbeappendedto.23REDIRECTlNGERGoROIJTPUTOftenacommandwillproducespecialoutput(errormessages)informingyouofproblemsthatitencounteredwhileexecuting.Thisiscallederroroutputordiagnosticoutput(abbreviatedstderr).Normallytheerroroutputappearsinterspersedwithstandardoutputonourterminal.Redirectingstandardoutputdoesnotredirecterroroutput.Forexample,supposethatisaonelinefilewhichcontains'abcdefandthatdoesnotexist.EXAMPLESbl.dat:NosuchfileordirectoryabcdefIfweredirectstandardoutput,westillseetheerrormessage:bl.dat:Nosuchfileordirectory.Wecanredirecterroroutputtogetherwithstandardoutputbyusingthe>&redirectionsymbol,asin:%command>&fileWecanappenderroroutputtogetherwithstandardoutputbyusingthe»&redirectionsymbol,asin:%command»&fileLookagainatthepreviousexample,thistimeredirectingbothstdoutandstderr:bl.dat:Nosuchfileordirectoryabcdef24SEPARATlNGSNANDARDOuTPIjTANDEiwoROUTPUTWecanusecommandgroupingwithredirectiontoseparatestandardoutputfromerroroutput.Forexample,supposethatwehaveaproductiontaskcalledcmd_lthatgeneratesstandardoutputandalsodiagnosticoutput.Toseparatethetwotypesofoutput,wecanuse:Theredirectionorderisimportant.Wemustuse>insidethecommandgroupand>&outside.TheCShellfirstopensforbothstandardoutputanderroroutputredirection.Thenitcreatesasubshelltoexecutethecommandgroup.Withinthesubshell,itopensforstandardoutputredirectiononly.Whencmd_lgeneratesstandardoutput,itiscapturedwithinthesubshell.Erroroutputispassedonbythesubshell,tobecollectedin.2.5THEBUILT-INNOCLOBBERVARIABLETheCShellhasabuilt-invariablecallednoclobberthatmaybeusedtosafeguardexistingfilesfrombeingoverwrittenthroughoutputredirection.Settingnoclobberalsopreventsfilecreationifwehavespecifiedanappend(»)redirectionoperation.Toactivatenoclobberprotection,type:%setnoclobberToturnitoff,use:%unsetnoclobberEXAMPLES%setnoclobber%date>users%whoami>users('users,notchanged)users:FileexistsNOTES%setnoclobber%date>users%whoami»users(willnotgiveanyerrormessage).Thesetnoclobberwillpreventthedeletionofthecontentofafilebutnottheadditionofnewdata.WecanforcetheCShelltooverridenoclobberprotectionbyaddinganexclamationpoint(!)foremphasisaftertheredirectionsymbol.%setnoclobber%date>users%whoami>!users('users*overwritten)Thefollowingappendcommandforcesthecreationofthefileevenifitdoesnotexist:%setnoclobberNOTESAspaceisalwaysrequiredaftertheexclamationpointwhenever!isappendedtoanyoutputredirectionoperator.ThisistopreventCshfromtryingtointerpretthe!andwhateverfollowsitasahistoryvariable.26REDIREDTlNGNPUTIfacommandrequiresinputdatawhileitisexecuting,thatinputistakenfromthestandardinputstream(abbreviatedstdin).Thestandardinputfilemaybere-directedwiththe<redirectionsymbol.THECOMMANDFORMAT%command<fileNoTES Aswithoutputredirection,spacearoundthe<symbolareoptional. Inputredirectionisveryusefulwithcommandsliketr(translate)andmailwhichonlyreadfromstandardinput.EXAMPLESSupposewehaveafilecalledthatcontainsonlyuppercasecharacters.Toconvertittoanalllowercaseequivalent,Weuse:WequotetheregularexpressionsA-Zanda-zsothattheCShellwon'ttrytotreatthemafilenamepatternstrings.Wediscussthistopicindetaillateron.27CONNECTlNGCOMMANDS:PlPEPManysequencesofcommandsrequiretheuseoftemporaryfilestostoreintermediateresults.Consider:%who>tmptemp;wc-1<tmptemp;rmtmptemp15TheCShellprovidesanimportantmechanismcalledapipe(thesymbolis)forconnectingtheoutputofonecommanddirectlytotheinputofthenext.Thiseliminatestheneedforanintermediatefile.Usingapipe,wecanabbreviatetheabovecommandto:%whoIwc-115Morethanonepipecanbeusedinasinglecommand.Forinstance,here'sacommandthatuses2pipestoconnect3components:%Is-11grep'-,sort-nrThiscommandliststhefilesinourCWD(longformat);usesgreptostripoutlinesbelongingtoordinaryfiles;andthensortsthesefilesbysizefromlargesttosmallest.Thepattern,-*tellsgreptolookforlinesthatbeginwiththecharacter"-n.InIsoutput,allsuchlinesbelongtoordinaryfiles.Usingthepattern*x$'wouldtellgreptolookforlinesthatendwiththecharacter"xn.Notes: Asequenceofcommandsconnectedbypipesisoftencalledapipeline. Commandslikegrepthatreaddatafromstandardinput,transformthedatasomehow,andwritethechangeddatatostandardoutputareoftencalledfilters.CoMMONFlLTERSINPIPELINESNameMeaningddUpper/Lowercaseconversion;alsoASCII/EBCDICtranslation.grepExtractslinesfromitsinputthatmatchagivenpattern.PrPrettyprintsitsinput.sedStreamEditor-editsinputlinesoneatatime.sortSortsitsinputinuser-specifiedways.trTranslateCharacters.uniqDeletesrepeatedlinesinafile.WCCountscharacters,wordsorlinesinitsinput.Thegeneralformatforusingpipesis:%cmd_lIcmd_2.cmd_nNotethatanycommandontheleftsideofthepipemustwritetostandardoutputandthatanycommandontherightsideofapipemustreadfromstandardinput.Toillustratewhathappensifthisrequirementisignored,let'strytoremoveallbackupfiles(extension.bak)inourCWDwithapipedcommand:%Is*.bakIrm-iTheproblemisthatrmexpectsitsargumentsonthecommandline,notinstandardinput.Ofcourse,wedon'tneedapipeforthistask;asimplerm*.baksuffices.28REDIRECTlNGSNANDARDERR。RTHROUGHPlPESOrdinarily,onlystandardoutputpassesthroughapipe,noterroroutput.Toredirectbothtypesofoutputthroughapipe,usethesymbol|&asin:%cmd_l|&cmd_2Supposewearesearchingforacertainclassoffilesandwewanttoreviewbothfilenamesanderrormessagesfromthebeginningofthelist.WECANUSE%find/-name*.bak-print|&moreshowsallerrormessagesplusallpathnamesfound.2.9SUMMARY Redirectionallowsustousefilesasthesourceofstandardinputandasthedestinationforstandardoutputanderroroutput. Outputcaneitheroverwritethecontentsofanexistingfileorbeappendedtoit. Thenoclobbervariablecanbesettoprotectexistingfilesfrombeinginadvertentlyoverwritten. Pipesallowustodirecttheoutputofonecommandintotheinputofanother. Aseriesofcommandsconnectedbypipesiscalledapipeline. Commandsinapipelineexecuteconcurrently.SUMMARYOFREDIREeTINGSYMBoLSSymbolMeaning<Redirectstandardinput(stdin)>Redirectstandardoutput(stdout)>&Redirectstandardoutputandstandarderror(stderr)>!Redirectstdout,overridenoclobber.>&!Redirectstdoutandstderr,overridenoclobber.»Appendstdout.»&Appendstdoutandstderr.»!Appendstdout,overridenoclobber.»&!Appendstdoutandstderr,overridenoclobber.IPipestdout.l&Pipestdoutandstderr.(cmd>filel)>&file2Redirectstdouttofilelandstderrtofile2.3.FILENAMEEXPANSION31RLENAMEEXPANSM)NMETACHARACTERSInmostshellcommands,theargumentthatarespecifiedafterthecommandnamearethenamesoffilesonwhichthecommandistooperate.EXAMPLES%rmfilelfile2file3Often,wewanttooperateonagroupofrelatedfilesordirectories.Wecanspecifygroupsofpathnamesbymeansofpatternscontainingspecialcharacterscalledmetacharactersorwildcardscharacters.METACHARACTERSALSoALLOWUSTo abbreviatelongpathnames. toaccessobjectswhosenamescontainunprintable(control)characters.FlLENAMEEXPANSIoNMETACHARAeTERSSymbolMeaning9Matchesanysinglecharacter,(e.g.:Isiee?)*Matchesanystringofcharactersofanylength,(e.g.:lsidworkfile*.bak)Matchesanyofthecharactersenclosedwithinthesquarebrackets,(e.g.:Isiei(adr?)fcl-c2Matchesanycharacterbetweenclandc2(inclus

    注意事项

    本文(奥宝gensis脚本培训(英文版).docx)为本站会员(夺命阿水)主动上传,课桌文档仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知课桌文档(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-1

    经营许可证:宁B2-20210002

    宁公网安备 64010402000986号

    课桌文档
    收起
    展开