?? ae7
字號:
.NHSUPPORTING TOOLS.PPThere are several tools and techniques that go along with theeditor, all of which are relatively easy once youknow how.UL edworks,because they are all based on the editor.In this section we will give some fairly cursory examplesof these tools,more to indicate their existence than to providea complete tutorial.More information on each can be found in[3]..SHGrep.PPSometimes you want to find all occurrences of some word or pattern ina set of files, to edit themor perhaps just to verify their presence or absence.It may be possible to edit each file separately and lookfor the pattern of interest, but if there are many filesthis can get very tedious,and if the files are really big,it may be impossible because of limits in .UL ed ..PPThe program.UL grepwas invented to get around these limitations.The search patterns that we have described in the paper are oftencalled `regular expressions', and`grep' stands for.P1g/re/p.P2That describes exactly what.UL grepdoes _it prints every line in a set of files that contains aparticular pattern.Thus.P1grep \(fmthing\(fm file1 file2 file3 ....P2finds `thing' wherever it occurs in any of the files`file1',`file2',etc..UL grepalso indicates the file in which the line was found,so you can later edit it if you like..PPThe pattern represented by `thing' can be anypattern you can use in the editor,since.UL grepand.UL eduse exactly the same mechanism forpattern searching.It is wisest always to enclose the pattern in thesingle quotes \(fm...\(fm if it contains any non-alphabeticcharacters, since many such characters also mean somethingspecial to the.UXcommand interpreter(the `shell').If you don't quote them, the command interpreter willtry to interpret them before.UL grepgets a chance..PPThere is also a way to find lines that.uldon't contain a pattern:.P1grep -v \(fmthing\(fm file1 file2 ....P2finds all lines thatdon't contains `thing'.The.UL \-vmust occur in the position shown.Given.UL grepand.UL grep\ \-v ,it is possible to do things like selecting all lines thatcontain some combination of patterns.For example, to get all lines that contain `x' but not `y':.P1grep x file... | grep -v y.P2(The notation | is a `pipe',which causes the output of the first command to be used asinput to the second command; see [2].).SHEditing Scripts.PPIf a fairly complicated set of editing operations is to be done on a whole set of files,the easiest thing to do is to make up a `script',i.e., a file that contains the operations you want to perform,then apply this script to each file in turn..PPFor example, suppose you want to change every`Unix' to `UNIX' and every `Gcos' to `GCOS' in a large number of files.Then put into the file `script' the lines.P1g/Unix/s//UNIX/gg/Gcos/s//GCOS/gwq.P2Now you can say.P1ed file1 <scripted file2 <script\&....P2This causes.UL edto take its commands from the prepared script.Notice that the whole job has to be planned in advance..PPAnd of course by using the.UXcommand interpreter, you cancycle through a set of filesautomatically, with varying degrees of ease..SHSed.PP.UL sed(`stream editor')is a version of the editor with restricted capabilitiesbut which is capable of processing unlimited amounts of input.Basically.UL sedcopies its input to its output, applying one or moreediting commands to each line of input..PPAs an example, suppose that we want to do the `Unix' to `UNIX'part of theexample given above,but without rewriting the files.Then the command.P1sed \(fms/Unix/UNIX/g\(fm file1 file2 ....P2applies the command`s/Unix/UNIX/g'to all lines from `file1', `file2', etc.,and copies all lines to the output.The advantage of using.UL sedin such a case is that it can be usedwith input too large for.UL edto handle.All the output can be collected in one place,either in a file or perhaps piped into another program..PPIf the editing transformation is so complicatedthatmore than one editing command is needed,commands can be supplied from a file,or on the command line,with a slightly more complex syntax.To take commands from a file, for example,.P1sed -f cmdfile input-files....P2.PP.UL sedhas further capabilities, including conditional testingand branching, which we cannot go into here.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -