⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e5

📁 UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱昂氏unix源代码分析都是用的该版
💻
字号:
.H1Change and Insert \(mi ``c'' and ``i''.H2.PGThis section discusses the.ulchangecommand.X1c.X2which is used to changeor replace a group of one or more lines,and the.ulinsertcommand.X1i.X2which is used for inserting a group of one or more lines..PG``Change'', written as.X1c.X2is used to replace a number of lines with different lines, whichare typed in at the terminal.For example,to change lines ``\*.+1'' through ``$'' to something else, type.X1 .+1,$c . . . \fItype the lines of text you want here\fP . . . \fB.\fR.X2The lines you type between the ``c'' command andthe ``\*.'' will take the place of the original lines betweenstart line and end line.This is most useful in replacing a lineor several lines which have errors in them..PGIf only one line is specified in the ``c'' command, then justthat line is replaced.(You can type in as many replacement lines as you like.)Noticethe use of ``\*.'' to end theinput \(mi this works just like the ``\*.'' in the append commandand must appear by itself on a new line.If no line number is given, line dot is replaced.The value of dot is set to the last line you typed in..PG``Insert'' is similar to append \(mi for instance.X1/string/i.li. . . \fItype the lines to be inserted here\fP . . ..li\fB.\fR.X2will insert the given text.ulbeforethe next line that contains ``string''.The text between ``i'' and ``\*.'' is.ulinserted beforethe specified line.If no line number is specified dot is used.Dot is set to the last line inserted..H1Exercise 7:.H2.PG``Change'' is rather like a combination ofdelete followed by insert.Experiment to verify that.X1\fIstart, end\fP di.ul . . . text . . ..li\fB.\fR.X2is almost the same as.X1\fIstart, end\fP c.ul . . . text . . ..li\fB.\fR.X2These are not.ulpreciselythe sameif line ``$'' gets deleted.Check this out.What is dot?.PGExperiment with ``a'' and ``i'', to see that they aresimilar, but not the same.You will observe that.X1\fIline-number\fP a.li. . . \fItext\fP . . ..li\fB.\fR.X2appends.ulafterthe given line, while.X1\fIline-number\fP i.li. . . \fItext\fP . . ..li\fB.\fR.X2inserts.ulbeforeit.Observe that if no line number is given,``i'' inserts before line dot, while ``a'' appendsafter line dot..H1Moving text around: the ``m'' command.H2.PGThe move command ``m'' is used for cutting and pasting \(miit lets you move a group of linesfrom one place to another in the buffer.Suppose we want to put the first three lines of the buffer at the end instead.We could do it by saying:.X11,3w temp$r temp1,3d.X2(Do you see why?)but we can do it a lot easier with the ``m'' command:.X11,3m$.X2The general case is.X1\fIstart line, end line\fP m \fIafter this line\fP.X2Notice that there is a third line to be specified \(mithe place where the moved stuff gets put.Of course the lines to be moved can be specifiedby context searches;if we had.X1First paragraph.li. . .end of first paragraph.Second paragraph.li. . .end of second paragraph..X2we could reverse the two paragraphs like this:.X1/Second/,/second/m/First/\(mi1.X2Notice the ``\(mi1'' \(mithe moved text goes.ulafterthe line mentioned.Dot gets set to the last line moved..H1The global commands ``g'' and ``v''.H2.PGThe.ulglobalcommand ``g'' is used to execute one or more .uledcommands on all those lines in the bufferthat match some specified string.For example.X1g/peling/p.X2prints all lines that contain ``peling''.More usefully,.X1g/peling/s//pelling/gp.X2makes the substitution everywhere on the line,then prints each corrected line.Compare this to.X11,$s/peling/pelling/gp.X2which only prints the last line substituted.Another subtle difference is thatthe ``g'' commanddoes not give a ``?'' if ``peling'' is not foundwhere the ``s'' command will..PGThere may be several commands(including ``a'', ``c'' ``i'' ``r'', ``w'', but not ``g'');in that case,every line except the last must end with a backslash ``\\'':.X1g/xxx/\*.-1s/abc/def/\\.li\fB.\fR+2s/ghi/jkl/\\.li\fB.\fR-2,\fB.\fRp.X2makes changes in the lines before and after each linethat contains ``xxx'',then prints all three lines..PGThe ``v'' command is the same as ``g'',except that the commands are executed on every linethat does.ulnotmatch the string following ``v'':.X1v/ /d.X2deletes every line that does not contain a blank.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -