Sie sind auf Seite 1von 5

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

UNIXEDITORS viEDITOR CommandLineSyntax: StartingtheSection: vifile vi+50file vi+/patternfile Endingthesection: :wq :q! viModes: Ithas2modes:commandmodeandinsertmode(editfile). SyntaxoftheCommands: [n]operator[m]motion Thebasiceditoperatorsare: ddelete yyank(copy) Ifthecurrentlineistheobjectofoperation,themotionisthesameastheoperator,thenuseddandyy. Otherwise,itwillworkliked}forexample,whereyoudeleteuntilthenextparagraph.Thenandmare thenumberoftimestoperformetheoperation,so5yymeanstocopy5lines. StatuslineCommands: Thesecommandsarenotechoedonthescreenasyouinputthem.Thestatusline(inthebottomofthe screen)isusedforeditingthem. /Seachforwardforapattern ?Searchbackwardforapattern :Invokeanexcommand 1 Savethemodificationsandquit. Quitwithoutsaving. Openthefileforediting Openthefileatline50forediting Openfile(wherepatternappearsthefirsttime)forediting.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

viCommands: Command /pattern n % fx Fx :num =% i dd d$ d} p u . yy y$ paste undo repeat copy delete search Action Repeatprevioussearch. Findmatchofcurrentparenthesis,braceorbracket. Movecursorforwardtoletterxoncurrentline. Movecursorbackwardtoletterxoncurrentline. linenumber Movetolinenumber. aligntext insert Positionthecursorinthelineofanopeningstatementcurlybracket,then pressESCand=%toalignthelines. Insertbeforecursor. Deletecurrentline. Deletefromcurrentpositiontoendofline. Deleteuptonextparagraph. Insertlastdeletedoryankedtextafterthecursor. Undolastchange. Repeatlastchange. Copycurrentline. Copyrestofline. exEDITOR Syntaxofexcommands: :[address]command[options] Address: Especifytheaddressusingarangeoflines:(x,y). Address 1,$(or%) Alllinesinthefile. Meaning Description Searchforwardforpattern.EndwithENTER.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Address x,y num 0 . $ /pattern/ Options: Option ! count file Commands: Command Linesxtoy. Absolutelinenumber. Topofline. Currentline. Lastline. Forwardtolinematchingpattern.

Meaning

Meaning Variantforofthecommand,mustcomeimmediatelyafterthecommand. Thenumberoftimesthecommandmustberepeated.Mustcomeafter,tonotbe interpretedasanaddress. Fileaffectedbythecommand.%standsforcurrentfileand#isthepreviousfile.

Meaning

[address]codestination Copythelinesspecifiedintheaddresstodestination. Examples: :1,10co50(copythefirst10linestojustafterline50) [address]d[register] Deletethelinesspecifiedintheaddess. Examples: :/PartI/,/PartII/1d(deletetolineabovePartII) :/main/+d(deletelinebelowmain) :.,$dx(deletefromtheactuallinetolastline,andstoreinregiterx) [address]mdestination Movethelinesspecifiedintheaddresstodestination. Examples: :1,10m50(movethefirst10linestojustafterline50) [address]pu[char] Putthepreviousdeletedfromnamedregisterchartothelinespecifiedby address.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Command

Meaning

[address]s Substitutethefirstinstanceofpatternoneachspecifiedlines(address) [/pattern/replacement/] withthereplacement.Countspecifiesthenumberoflinetoexecutestarting [options][count] tocountfromaddress. Options: cPromptforconfirmationbeforeeachsubstitution. gSubstituteallinstancesofpatternoneachline(global) Examples: :1,10s/yes/no/g(Substituteinfirst10lines) :%s/[Hh]ello/Hi/gc(confirmglobalsubstitutionstobeexecutedinalllines) [address]w[!][[>>]file] Writelinesspecifiedbyaddresstofile.If>>isused,thenappendtofile. Theoprtion!meanstoforcethewritingprocess. :1,10wfilename(copyfirst10linestofinename) :50w>>filename(appendline50tofilename) sedEDITOR Thesed(streameditor)isanoninteractiveeditor.Itinterpretsascriptandperformstheactions.Itisa usefuleditorforeditingmanyfilesautomatically. CommandLineSyntax: sed'command'file(s) sedfscriptfilefile(s) SyntaxofsedCommands: [address[,address]][!]command[arguments] Address /pattern/ N $ noaddress Meaning Linesthatmatchpattern. /BSD/d(deletelinesconatiningBSD) LinenumberN. Lastline. Eachinputline. s/xx/yy/g(substituteonalllines)

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Address Oneaddress

Meaning Anylinematchingtheaddress

Firstmatchinglineandallsucceedinglinesuptoandincludinga Twocommaseparetedaddresses linematchingthesecondaddress. /^begin/,/^end/p(printbetweenbeginandend,inclusive) Anaddressfollowedby! Commands: Command [address]a\text Appendtextfollowingeachlinethatmatchtheaddress. Iftextextendsmorethanoneline,useabackslash(\)attheendofthe linetobeginthenewline.LastlinedoesNOThavethe\(changeline). $a\ Thisisthefirstlineoftext\ secondline\ lastline. Changethelinesselectedbytheaddresseswithtext.Textfollowthe samerulesasusedforappend(a\). 1,100c\ firstline\ secondline. Deletethelinesspecifiedbytheaddress. Substitutepatterntoreplacementoneachlineaddressed.Theflagsare: nreplacethenthinstanceofpatternineachlineinsteadofthe1st (default) greplaceallinstanceofpatternoneachlineaddressed(global). Translatecharacters.Changeeveryinstanceofatox,btoy,ctoz,etc. AlllinesthatdoNOTmatchtheaddress.

[address[,address]]c\text

[address[,address]]d [address[,address]]s/ pattern/replacement/[flags]

[address[,address]]y/ abc/xyz/

Das könnte Ihnen auch gefallen