diff options
-rw-r--r-- | bin/ed/USD.doc/09.edtut/Makefile | 7 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e.mac | 73 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e0 | 69 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e1 | 279 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e2 | 463 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e3 | 419 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e4 | 303 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e5 | 310 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e6 | 279 | ||||
-rw-r--r-- | bin/ed/USD.doc/09.edtut/e7 | 227 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/Makefile | 7 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae.mac | 87 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae0 | 99 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae1 | 108 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae2 | 1051 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae3 | 504 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae4 | 218 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae5 | 359 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae6 | 528 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae7 | 220 | ||||
-rw-r--r-- | bin/ed/USD.doc/10.edadv/ae9 | 58 |
21 files changed, 5668 insertions, 0 deletions
diff --git a/bin/ed/USD.doc/09.edtut/Makefile b/bin/ed/USD.doc/09.edtut/Makefile new file mode 100644 index 00000000000..dfd22103d7b --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2003/06/26 15:22:51 mickey Exp $ + +DIR= usd/09.edtut +SRCS= e.mac e0 e1 e2 e3 e4 e5 e6 e7 +MACROS= -ms + +.include <bsd.doc.mk> diff --git a/bin/ed/USD.doc/09.edtut/e.mac b/bin/ed/USD.doc/09.edtut/e.mac new file mode 100644 index 00000000000..46b4ac70d3d --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e.mac @@ -0,0 +1,73 @@ +.\" $OpenBSD: e.mac,v 1.1 2003/06/26 15:22:51 mickey Exp $ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e.mac 8.1 (Berkeley) 8/14/93 +.\" +.ds . \&\s+2.\s0\& +.de UC +\&\\$3\s-1\\$1\s0\\$2 +.. +.de UL +.if t \&\\$3\f3\\$1\f1\\$2 +.if n \&\\$3\f2\\$1\f1\\$2 +.. +.de IT +\&\\$3\f2\\$1\fP\\$2 +.. +.de UI +\f3\\$1\fI\\$2\fR\\$3 +.. +.de P1 +.if n .ls 1 +.nf +.if n .ta 5 10 15 20 25 30 35 40 45 50 55 60 +.if t .ta .3i .6i .9i 1.2i 1.5i 1.8i +.tr -\- +.\" use first argument as indent if present +.if \\n(.$ .DS I \\$1 +.if !\\n(.$ .DS I 5 +.bd 1 2 +.. +.de P2 +.br +.bd 1 2 +.DE +.bd 1 +.tr -- +.if n .ls 2 +.. +.hy 14 +.\" 2=not last lines; 4= no -xx; 8=no xx- +.tr *\(** +.nr PI .2i diff --git a/bin/ed/USD.doc/09.edtut/e0 b/bin/ed/USD.doc/09.edtut/e0 new file mode 100644 index 00000000000..dd2f42749f2 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e0 @@ -0,0 +1,69 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e0 8.1 (Berkeley) 8/14/93 +.\" +.EH 'USD:9-%''A Tutorial Introduction to the \s-2UNIX\s+2 Text Editor' +.OH 'A Tutorial Introduction to the \s-2UNIX\s+2 Text Editor''USD:9-%' +.\".RP +.TL +A Tutorial Introduction to the \s-2UNIX\s+2 Text Editor +.AU +Brian W. Kernighan +.AI +Murray Hill, NJ +.AB +.PP +Almost all text input on +the +.UX +operating system +is done with +the text-editor +.IT ed . +This memorandum is a tutorial guide +to help beginners get started +with text editing. +.PP +Although it does not cover everything, +it does discuss enough for most users' +day-to-day needs. +This includes +printing, appending, changing, deleting, moving and inserting entire lines of text; +reading and writing files; +context searching and line addressing; +the substitute command; +the global commands; +and the use of special characters for advanced editing. +.AE diff --git a/bin/ed/USD.doc/09.edtut/e1 b/bin/ed/USD.doc/09.edtut/e1 new file mode 100644 index 00000000000..cbec1196e79 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e1 @@ -0,0 +1,279 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e1 8.1 (Berkeley) 6/8/93 +.\" +.nr PS 9 +.nr VS 11 +.if t .2C +.SH +Introduction +.PP +.ul +Ed +is a ``text editor'', that is, an interactive program +for creating and modifying ``text'', +using directions provided by a user at +a terminal. +The text is often a document +like this one, +or a program +or perhaps data for a program. +.PP +This introduction is meant to simplify learning +.ul +ed. +The recommended way to learn +.ul +ed +is to read this document, +simultaneously using +.ul +ed +to follow the examples, +then to read the description in section I of the +.ul +.UC UNIX +.ul +Programmer's Manual, +all the while +experimenting with +.ul +ed. +(Solicitation of advice from experienced users is also useful.) +.PP +Do the exercises! +They cover material not completely discussed +in the actual text. +An appendix summarizes the commands. +.SH +Disclaimer +.PP +This is an introduction and a tutorial. +For this reason, no attempt is made to +cover more than a part of the facilities that +.ul +ed +offers +(although this fraction includes the most useful and frequently used +parts). +When you have mastered the Tutorial, +try +.ul +Advanced Editing on +.ul +.UC UNIX . +Also, +there is not enough space to explain basic +.UC UNIX +procedures. +We will assume that you know how to log on to +.UC UNIX , +and that you have at least a vague understanding +of what a file is. +For more on that, read +.ul +.UC UNIX +.ul +for Beginners. +.PP +You must also know what character to type as the end-of-line +on your particular terminal. +This character is the +.UC RETURN +key on most terminals. +Throughout, we will refer to this character, +whatever it is, +as +.UC RETURN . +.SH +Getting Started +.PP +We'll assume that you have logged in to +your system +and it has just printed the prompt character, +usually either a +.UL $ +or a +.UL % . +The +easiest way to get +.ul +ed +is to type +.P1 +ed (followed by a return) +.P2 +You are now ready to go \- +.ul +ed +is waiting for you to tell it what to do. +.SH +Creating Text \- the Append command ``a'' +.PP +As your first problem, suppose you want to create some text +starting from scratch. +Perhaps you are typing the very first +draft of a paper; clearly it will have to start +somewhere, and undergo modifications later. +This section will show how to get some text in, just to +get started. +Later we'll talk about how to change it. +.PP +When +.ul +ed +is first started, it is rather like working +with a blank piece of paper \- there is no text +or information present. +This must be supplied by the person using +.ul +ed; +it is usually done +by typing in the text, or by reading it into +.ul +ed +from a +file. +We will start by typing in some text, and return shortly to how to +read files. +.PP +First a bit of terminology. +In +.ul +ed +jargon, the text being +worked on is said to be ``kept in a buffer.'' +Think of the +buffer as a work space, if you like, or simply as the information +that you are going to be editing. +In effect the buffer is like the +piece of paper, on which we will write things, then change some +of them, and finally file the whole thing away for another day. +.PP +The user tells +.ul +ed +what to do to his text +by typing instructions called ``commands.'' +Most +commands consist of a single letter, +which must be typed in lower case. +Each command is typed +on a separate line. +(Sometimes the command is preceded by information +about what line or lines of text are to be affected \- +we will discuss these shortly.) +.ul +Ed +makes no response +to most commands \- there is no prompting +or typing of messages like ``ready''. +(This silence is preferred +by experienced users, but sometimes a hangup for beginners.) +.PP +The first command is +.ul +append, +written as the letter +.P1 +a +.P2 +all +by itself. +It means ``append (or add) text lines to the buffer, +as I type them in.'' +Appending is rather like +writing fresh material on a piece of paper. +.PP +So to enter lines of text into the buffer, +just type an +.UL a +followed by a +.UC RETURN , +followed by the lines of text you want, like this: +.P1 +a +Now is the time +for all good men +to come to the aid of their party. +\*. +.P2 +.PP +The only way to stop appending is to type a +line that contains only a period. +The ``\*.'' is used +to tell +.ul +ed +that you have finished appending. +(Even experienced users forget that terminating ``\*.'' +sometimes. +If +.ul +ed +seems to be ignoring you, +type an extra line with just ``\*.'' on it. +You may then find you've added some garbage lines +to your text, which you'll have to take out later.) +.PP +After the append command has been done, the buffer will +contain the three lines +.P1 +Now is the time +for all good men +to come to the aid of their party. +.P2 +The +.UL a '' `` +and ``\*.'' aren't there, because they are +not text. +.PP +To add more text to what you already have, +just issue another +.UL a +command, and continue typing. +.SH +Error Messages \- ``?'' +.PP +If at any time you make an error in the commands you type to +.ul +ed, +it will tell you by typing +.P1 +? +.P2 +This is about as cryptic as it can be, +but with practice, you can usually +figure out how you goofed. diff --git a/bin/ed/USD.doc/09.edtut/e2 b/bin/ed/USD.doc/09.edtut/e2 new file mode 100644 index 00000000000..436cecff42c --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e2 @@ -0,0 +1,463 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e2 8.1 (Berkeley) 6/8/93 +.\" +.SH +Writing text out as a file \- the Write command ``w'' +.PP +It's likely that you'll want to save your text for later use. +To write out the contents of the buffer onto a file, +use the +.ul +write +command +.P1 +w +.P2 +followed by the filename you want to write on. +This will copy the buffer's contents +onto the specified file +(destroying any previous information on the file). +To save +the text on a file named +.UL junk , +for example, type +.P1 +w junk +.P2 +Leave a space between +.UL w +and the file name. +.ul +Ed +will respond by printing +the number of characters it wrote out. +In this case, +.ul +ed +would respond with +.P1 +68 +.P2 +(Remember that blanks and the return character at the end of each +line are included in the character count.) +Writing a file just makes a copy of the text \- the +buffer's contents are not disturbed, so you can go on adding +lines to it. +This is an important point. +.ul +Ed +at all times works on a copy +of a file, not the file itself. +No change in the contents +of a file takes place until you give a +.UL w +command. +(Writing out the text onto a file from time to time as it is being +created is a good idea, since if the system crashes or if you make some horrible mistake, you will lose +all the text in the buffer but any text that was written onto +a file is relatively safe.) +.SH +Leaving ed \- the Quit command ``q'' +.PP +To terminate a session with +.IT ed , +save the text you're working on +by writing it onto a file using the +.UL w +command, +and then type the command +.P1 +q +.P2 +which +stands for +.IT quit . +The system will respond with +the prompt character +.UL $ "" ( +or +.UL % ). +At +this point your buffer vanishes, with all its text, +which is why you want to write it out before quitting.\(dg +.FS +\(dg Actually, +.IT ed +will print +.UL ? +if you try to quit without writing. +At that point, write if you want; +if not, another +.UL q +will get you out regardless. +.FE +.SH +Exercise 1: +.PP +Enter +.ul +ed +and +create some text using +.P1 +a +\&. . . text . . . +\&\fB.\fR +.P2 +Write it out using +.UL w . +Then leave +.ul +ed +with the +.UL q +command, and print the file, +to see that everything worked. +(To print a file, say +.P1 +pr filename +.P2 +or +.P1 +cat filename +.P2 +in response to +the prompt character. +Try both.) +.SH +Reading text from a file \- the Edit command ``e'' +.PP +A common way to get text into the buffer is to read it +from a file in the file system. +This is what you do to edit text +that you saved with the +.UL w +command in a previous session. +The +.ul +edit +command +.UL e +fetches the entire contents of a file into the buffer. +So if you had saved the three lines +``Now is the time'', etc., +with a +.UL w +command in an earlier session, +the +.ul +ed +command +.P1 +e junk +.P2 +would fetch the entire contents of the file +.UL junk +into the buffer, and respond +.P1 +68 +.P2 +which is the number of characters in +.UL junk . +.ul +If anything was already in the buffer, it is deleted first. +.PP +If you use the +.UL e +command to read a file into the buffer, +then you need not use a file name after a subsequent +.UL w +command; +.ul +ed +remembers the last file name used in an +.UL e +command, +and +.UL w +will write on this file. +Thus a good way to operate is +.P1 +ed +e file +[editing session] +w +q +.P2 +This way, you can simply say +.UL w +from time to time, +and be secure in the knowledge that +if you got the file name right at the beginning, +you are writing into the proper file each time. +.PP +You can find out at any time what file name +.ul +ed +is remembering by typing the +.ul +file +command +.UL f . +In this example, +if you typed +.P1 +f +.P2 +.ul +ed +would reply +.P1 +junk +.P2 +.SH +Reading text from a file \- the Read command ``r'' +.PP +Sometimes you want to read a file into the buffer +without destroying anything that is already there. +This is done by the +.ul +read +command +.UL r . +The command +.P1 +r junk +.P2 +will read the file +.UL junk +into the buffer; +it adds it +to the end of whatever is already in the buffer. +So if you do a read after +an edit: +.P1 +e junk +r junk +.P2 +the buffer will contain +.ul +two +copies of the text (six lines). +.P1 +Now is the time +for all good men +to come to the aid of their party. +Now is the time +for all good men +to come to the aid of their party. +.P2 +Like the +.UL w +and +.UL e +commands, +.UL r +prints +the +number of characters read in, after the reading operation is complete. +.PP +Generally speaking, +.UL r +is much less used than +.UL e . +.SH +Exercise 2: +.PP +Experiment with the +.UL e +command \- +try reading and printing various files. +You may get an error +.UL ?name , +where +.UL name +is the name of a file; +this means that the file doesn't exist, +typically because you spelled the file name wrong, +or perhaps that you are not allowed to read or write it. +Try alternately reading and appending to see that they work +similarly. +Verify that +.P1 +ed filename +.P2 +is exactly equivalent to +.P1 +ed +e filename +.P2 +What does +.P1 +f filename +.P2 +do? +.SH +Printing the contents of the buffer \- the Print command ``p'' +.PP +To +.ul +print +or list the contents of the buffer (or parts +of it) on the terminal, use the print command +.P1 +p +.P2 +The way this is done is as follows. +Specify the lines where +you want printing to begin and where you want it to end, +separated by a comma, and +followed by the letter +.UL p . +Thus to print the first two lines of the buffer, for +example, (that is, lines 1 through 2) say +.P1 +1,2p (starting line=1, ending line=2 p) +.P2 +.ul +Ed +will respond with +.P1 +Now is the time +for all good men +.P2 +.PP +Suppose you want to print +.ul +all +the lines in the buffer. +You could use +.UL 1,3p +as above if you knew there were exactly +3 lines in the buffer. +But in general, you don't +know how many there are, so what do you use for the ending +line number? +.ul +Ed +provides a shorthand symbol for ``line number of +last line in buffer'' \- the dollar sign +.UL $ . +Use it this +way: +.P1 +1,$p +.P2 +This will print +.ul +all +the lines in the buffer (line 1 to last line.) +If you want to stop the printing before it is finished, +push the +.UC DEL +or Delete key; +.ul +ed +will type +.P1 +? +.P2 +and wait for the next command. +.PP +To print the +.ul +last +line of the buffer, you could use +.P1 +$,$p +.P2 +but +.ul +ed +lets you abbreviate this to +.P1 +$p +.P2 +You can print any single line by typing the line +number followed by a +.UL p . +Thus +.P1 +1p +.P2 +produces the response +.P1 +Now is the time +.P2 +which is the first line of the buffer. +.PP +In fact, +.ul +ed +lets you abbreviate even further: +you can print any single line by typing +.ul +just +the line number \- no need to type the letter +.UL p . +So if you say +.P1 +$ +.P2 +.ul +ed +will print the last line of the buffer. +.PP +You can also use +.UL $ +in combinations like +.P1 +$\-1,$p +.P2 +which prints the last two lines of the buffer. +This helps when you want to see how far you got in typing. +.SH +Exercise 3: +.PP +As before, create some text using the +.UL a +command and +experiment with the +.UL p +command. +You will find, for example, +that you can't print line 0 or a line beyond +the end of the buffer, and that attempts +to print a buffer in reverse order by saying +.P1 +3,1p +.P2 +don't work. diff --git a/bin/ed/USD.doc/09.edtut/e3 b/bin/ed/USD.doc/09.edtut/e3 new file mode 100644 index 00000000000..e0997fd0889 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e3 @@ -0,0 +1,419 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e3 8.1 (Berkeley) 6/8/93 +.\" +.SH +The current line \- ``Dot'' or ``.'' +.PP +Suppose your buffer still contains the six lines as above, +that you have just typed +.P1 +1,3p +.P2 +and +.ul +ed +has printed the three lines for you. +Try typing just +.P1 +p (no line numbers) +.P2 +This will print +.P1 +to come to the aid of their party. +.P2 +which is the third line of the buffer. +In fact it is the last +(most recent) line that you have done anything with. +(You just printed it!) +You can +repeat this +.UL p +command without line numbers, and +it will continue to print line 3. +.PP +The reason is that +.ul +ed +maintains a record of the last line +that you did anything to (in this case, line 3, which you +just printed) so that it can be used instead of an explicit +line number. +This most recent line is referred to by the +shorthand symbol +.P1 +\&\*. (pronounced ``dot''). +.P2 +Dot is a line number in the same way that +.UL $ +is; it means +exactly ``the current line'', or loosely, +``the line you most recently did something to.'' +You +can use it in several ways \- one possibility +is to say +.P1 +\&\*.,$p +.P2 +This will print all the lines from (including) the current +line to the +end of the buffer. +In our example these are lines 3 through 6. +.PP +Some commands change the value of dot, while others do not. +The +.UL p +command sets dot to the number of the last line printed; +the last command will +set both +\*. +and +.UL $ +to 6. +.PP +Dot is most useful when used in combinations like this one: +.P1 +\&\*.+1 (or equivalently, \*.+1p) +.P2 +This means ``print the next line'' and is a handy way to step +slowly through a buffer. +You can also say +.P1 +\&\*.\-1 (or \*.\-1p ) +.P2 +which means ``print the line +.ul +before +the current line.'' +This enables you to go backwards if you wish. +Another useful one is something like +.P1 +\&\*.\-3,\*.\-1p +.P2 +which prints the previous three lines. +.PP +Don't forget that all of these change the value of dot. +You can find out what dot is at any time by typing +.P1 +\&\*.= +.P2 +.ul +Ed +will respond by printing the value of dot. +.PP +Let's summarize some things about the +.UL p +command +and dot. +Essentially +.UL p +can be preceded by 0, 1, or 2 line numbers. +If there is no line number given, it prints the ``current line'', +the line that dot refers to. +If there is one line number given +(with or without the letter +.UL p ), +it prints that line (and dot is set there); and if there +are two line numbers, it prints all the lines in that range +(and sets dot to the last line printed.) +If two line numbers are specified +the first can't be bigger than the second (see Exercise 2.) +.PP +Typing a single return will cause printing of the next line \- +it's +equivalent to +.UL .+1p . +Try it. +Try typing +a +.UL \- ; +you will find that +it's equivalent to +.UL .\-1p . +.SH +Deleting lines: the ``d'' command +.PP +Suppose you want to get rid of the three extra lines in the buffer. +This is done by the +.ul +delete +command +.P1 +d +.P2 +Except that +.UL d +deletes lines instead of printing them, +its action is similar to that of +.UL p . +The lines to be deleted are specified for +.UL d +exactly as they are for +.UL p : +.P1 +\fIstarting line, ending line\fP d +.P2 +Thus the command +.P1 +4,$d +.P2 +deletes lines 4 through the end. +There are now three lines left, as you can check by using +.P1 +1,$p +.P2 +And notice that +.UL $ +now is line 3! +Dot +is set to the next line after the last line deleted, +unless the last line deleted is the last line in the buffer. +In that case, dot is set to +.UL $ . +.SH +Exercise 4: +.PP +Experiment with +.UL a , +.UL e , +.UL r , +.UL w , +.UL p +and +.UL d +until you are sure that you +know what they do, and until you understand how dot, +.UL $ , +and +line numbers are used. +.PP +If you are adventurous, try using line numbers with +.UL a , +.UL r +and +.UL w +as well. +You will find that +.UL a +will append lines +.ul +after +the line number that you specify (rather than after dot); that +.UL r +reads +a file in +.ul +after +the line number you specify (not necessarily +at the end of the buffer); and that +.UL w +will write out exactly the lines +you specify, not necessarily the whole buffer. +These variations are sometimes handy. +For instance you can insert a file at the beginning of a buffer +by saying +.P1 +0r filename +.P2 +and you can enter lines at the beginning of the buffer +by saying +.P1 +0a +\&. . . \fItext\fP . . . +\*. +.P2 +Notice that +.UL .w +is +.ul +very +different from +.P1 +\*. +w +.P2 +.SH +Modifying text: the Substitute command ``s'' +.PP +We are now ready to try one of the most important +of all commands \- the substitute command +.P1 +s +.P2 +This is the command +that is used to change individual +words or letters within a line or group of lines. +It is what you use, for example, for correcting spelling +mistakes and typing errors. +.PP +Suppose that by a typing error, line 1 says +.P1 +Now is th time +.P2 +\- the +.IT e +has been left off +.IT the . +You can use +.UL s +to fix this up as follows: +.P1 +1s/th/the/ +.P2 +This says: ``in line 1, substitute for the characters +.IT th +the characters +.IT the .'' +To verify +that it works +.IT ed "" ( +will not print +the result automatically) say +.P1 +p +.P2 +and get +.P1 +Now is the time +.P2 +which is what you wanted. +Notice that dot must have been set to the line +where the substitution took place, since the +.UL p +command +printed that line. +Dot is always set this way with the +.UL s +command. +.PP +The general way to use the substitute command is +.P1 +\fIstarting\(hyline, ending\(hyline\fP s/\fIchange this\fP/\fIto this\fP/ +.P2 +Whatever string of characters is between the first pair of +slashes is replaced by whatever is between the second pair, +in +.ul +all +the lines between +.ul +starting-line +and +.ul +ending-line. +Only the first occurrence on each line is changed, however. +If you want to change +.ul +every +occurrence, see Exercise 5. +The rules for line numbers are the same as those for +.UL p , +except that dot is set to the last line changed. +(But there is a trap for the unwary: if no substitution +took place, dot is +.ul +not +changed. +This causes an error +.UL ? +as a warning.) +.PP +Thus you can say +.P1 +1,$s/speling/spelling/ +.P2 +and correct the first spelling mistake +on each line +in the text. +(This is useful for people who are consistent +misspellers!) +.PP +If no line numbers are given, the +.UL s +command assumes we mean +``make the substitution on line dot'', so it changes things only +on the current line. +This leads to the very common sequence +.P1 +s/something/something else/p +.P2 +which makes some correction on the +current line, and then prints it, to make sure it +worked out right. +If it didn't, +you can try again. +(Notice that there is +a +.UL p +on the same line as the +.UL s +command. +With few exceptions, +.UL p +can follow any command; +no other multi-command lines are legal.) +.PP +It's also legal to say +.P1 +s/ . . . // +.P2 +which means ``change the first +string of characters to +.IT nothing '', `` +i.e., +remove them. +This is useful for deleting extra words in a line or removing extra +letters from words. +For instance, if you had +.P1 +Nowxx is the time +.P2 +you can say +.P1 +s/xx//p +.P2 +to get +.P1 +Now is the time +.P2 +Notice that +.UL // +(two adjacent slashes) means ``no characters'', not a blank. +There +.ul +is +a difference! +(See below for another meaning of +.UL // .) diff --git a/bin/ed/USD.doc/09.edtut/e4 b/bin/ed/USD.doc/09.edtut/e4 new file mode 100644 index 00000000000..bcfec2ada6f --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e4 @@ -0,0 +1,303 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e4 8.1 (Berkeley) 6/8/93 +.\" +.SH +Exercise 5: +.PP +Experiment with the substitute command. +See what happens if you +substitute for some word on a line with several occurrences of that word. +For example, do this: +.P1 +a +the other side of the coin +\*. +s/the/on the/p +.P2 +You will get +.P1 +on the other side of the coin +.P2 +A substitute command changes only the first occurrence of the first string. +You can change all occurrences by adding a +.UL g +(for ``global'') +to the +.UL s +command, like this: +.P1 +s/ . . . / . . . /gp +.P2 +Try other characters instead of slashes to delimit the two sets +of characters in the +.UL s +command \- anything should work +except blanks or tabs. +.PP +(If you get funny results using any of the characters +.P1 +^ \*. $ [ * \e & +.P2 +read the section on ``Special Characters''.) +.SH +Context searching \- ``/ . . . /'' +.PP +With the substitute command mastered, you can move on to +another highly important idea of +.ul +ed +\- context searching. +.PP +Suppose you have the original three line text in the buffer: +.P1 +Now is the time +for all good men +to come to the aid of their party. +.P2 +Suppose you want to find the line that contains +.IT their +so +you can change it to +.IT the . +Now with only three lines in the buffer, it's pretty easy +to keep track of what line the word +.IT their +is on. +But if the buffer contained several hundred lines, +and you'd been making changes, deleting and rearranging lines, +and so on, you would no longer really know what this line +number would be. +Context searching is simply a method of specifying the desired line, +regardless of what its number is, +by specifying some context on it. +.PP +The way to say ``search for a line +that contains this particular string of characters'' +is to type +.P1 +/\fIstring of characters we want to find\fP/ +.P2 +For example, +the +.ul +ed +command +.P1 +/their/ +.P2 +is a context search which +is sufficient to find the desired line \- +it will locate the next occurrence of +the characters between slashes (``their''). +It also sets dot to that line +and prints the line for verification: +.P1 +to come to the aid of their party. +.P2 +``Next occurrence'' means that +.ul +ed +starts looking for the string at line +.UL .+1 , +searches to the end of the buffer, +then continues at line 1 and searches to line dot. +(That is, the search ``wraps around'' from +.UL $ +to +1.) +It scans all the lines in the buffer until it either finds the desired line +or gets back to dot again. +If the given string of characters can't be found in any line, +.ul +ed +types the error message +.P1 +? +.P2 +Otherwise it prints the line it found. +.PP +You can do both the search for the desired line +.ul +and +a +substitution all at once, like this: +.P1 +/their/s/their/the/p +.P2 +which will yield +.P1 +to come to the aid of the party. +.P2 +There were three parts to that last command: +context search for the desired line, make the substitution, print the line. +.PP +The expression +.UL /their/ +is a context search expression. +In their simplest form, +all context search expressions are like this \- +a string of characters surrounded by slashes. +Context searches are interchangeable with line numbers, +so they can be used by themselves to find and print a desired line, +or as line numbers for some other command, like +.UL s . +They were used both ways in the examples above. +.PP +Suppose the buffer contains the three familiar lines +.P1 +Now is the time +for all good men +to come to the aid of their party. +.P2 +Then the +.ul +ed +line numbers +.P1 +/Now/+1 +/good/ +/party/\-1 +.P2 +are all context search expressions, and they all refer +to the same line (line 2). +To make a change in line 2, +you could say +.P1 +/Now/+1s/good/bad/ +.P2 +or +.P1 +/good/s/good/bad/ +.P2 +or +.P1 +/party/\-1s/good/bad/ +.P2 +The choice is dictated only by convenience. +You could print all three lines by, for instance +.P1 +/Now/,/party/p +.P2 +or +.P1 +/Now/,/Now/+2p +.P2 +or by any number of similar combinations. +The first one of these might be better if you don't +know how many lines are involved. +(Of course, if there were only three lines in the buffer, +you'd use +.P1 +1,$p +.P2 +but not if there were several hundred.) +.PP +The basic rule is: a context search expression is +.ul +the same as +a line number, so it can be used wherever a line number is needed. +.SH +Exercise 6: +.PP +Experiment with context searching. +Try a body of text with +several occurrences +of the same string of characters, and scan through it using +the same context search. +.PP +Try using context searches as line numbers for the +substitute, print and delete commands. +(They can also be used +with +.UL r , +.UL w , +and +.UL a .) +.PP +Try context searching using +.UL ?text? +instead of +.UL /text/ . +This scans lines in the buffer in reverse order +rather than normal. +This is +sometimes useful if you go too far while looking for some +string of characters \- it's an easy way to back up. +.PP +(If you get funny results with any of the characters +.P1 +^ \*. $ [ * \e & +.P2 +read the section on ``Special Characters''.) +.PP +.ul +Ed +provides a shorthand for repeating a context search +for the same string. +For example, +the +.ul +ed +line number +.P1 +/string/ +.P2 +will find the next occurrence of +.UL string . +It often happens that this is not the desired line, +so the search must be repeated. +This can be done by typing merely +.P1 +// +.P2 +This shorthand stands for ``the most recently used +context search expression.'' +It can +also be used as the first string of the substitute +command, as in +.P1 +/string1/s//string2/ +.P2 +which will find the next occurrence of +.UL string1 +and replace it by +.UL string2 . +This can save a lot of typing. +Similarly +.P1 +?? +.P2 +means ``scan backwards for the same expression.'' diff --git a/bin/ed/USD.doc/09.edtut/e5 b/bin/ed/USD.doc/09.edtut/e5 new file mode 100644 index 00000000000..0d4ab60e0b8 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e5 @@ -0,0 +1,310 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e5 8.1 (Berkeley) 6/8/93 +.\" +.SH +Change and Insert \- ``c'' and ``i'' +.PP +This section discusses the +.ul +change +command +.P1 +c +.P2 +which is used to change +or replace a group of one or more lines, +and the +.ul +insert +command +.P1 +i +.P2 +which is used for inserting a group of one or more lines. +.PP +``Change'', written as +.P1 +c +.P2 +is used to replace a number of lines with different lines, which +are typed in at the terminal. +For example, +to change lines +.UL .+1 +through +.UL $ +to something else, type +.P1 +\&.+1,$c +\&. . . \fItype the lines of text you want here\fP . . . +\*. +.P2 +The lines you type between the +.UL c +command and +the +.UL . +will take the place of the original lines between +start line and end line. +This is most useful in replacing a line +or several lines which have errors in them. +.PP +If only one line is specified in the +.UL c +command, then just +that line is replaced. +(You can type in as many replacement lines as you like.) +Notice +the use of +.UL . +to end the +input \- this works just like the +.UL . +in the append command +and 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. +.PP +``Insert'' is similar to append \- for instance +.P1 +/string/i +\&. . . \fItype the lines to be inserted here\fP . . . +\*. +.P2 +will insert the given text +.ul +before +the next line that contains ``string''. +The text between +.UL i +and +.UL . +is +.ul +inserted before +the specified line. +If no line number is specified dot is used. +Dot is set to the last line inserted. +.SH +Exercise 7: +.PP +``Change'' is rather like a combination of +delete followed by insert. +Experiment to verify that +.P1 +\fIstart, end\fP d +i +.ul +\&. . . text . . . +\*. +.P2 +is almost the same as +.P1 +\fIstart, end\fP c +.ul +\&. . . text . . . +\*. +.P2 +These are not +.ul +precisely +the same +if line +.UL $ +gets deleted. +Check this out. +What is dot? +.PP +Experiment with +.UL a +and +.UL i , +to see that they are +similar, but not the same. +You will observe that +.P1 +\fIline\(hynumber\fP a +\&. . . \fItext\fP . . . +\*. +.P2 +appends +.ul +after +the given line, while +.P1 +\fIline\(hynumber\fP i +\&. . . \fItext\fP . . . +\*. +.P2 +inserts +.ul +before +it. +Observe that if no line number is given, +.UL i +inserts before line dot, while +.UL a +appends +after line dot. +.SH +Moving text around: the ``m'' command +.PP +The move command +.UL m +is used for cutting and pasting \- +it lets you move a group of lines +from one place to another in the buffer. +Suppose you want to put the first three lines of the buffer at the end instead. +You could do it by saying: +.P1 +1,3w temp +$r temp +1,3d +.P2 +(Do you see why?) +but you can do it a lot easier with the +.UL m +command: +.P1 +1,3m$ +.P2 +The general case is +.P1 +\fIstart line, end line\fP m \fIafter this line\fP +.P2 +Notice that there is a third line to be specified \- +the place where the moved stuff gets put. +Of course the lines to be moved can be specified +by context searches; +if you had +.P1 +First paragraph +\&. . . +end of first paragraph. +Second paragraph +\&. . . +end of second paragraph. +.P2 +you could reverse the two paragraphs like this: +.P1 +/Second/,/end of second/m/First/\-1 +.P2 +Notice the +.UL \-1 : +the moved text goes +.ul +after +the line mentioned. +Dot gets set to the last line moved. +.SH +The global commands ``g'' and ``v'' +.PP +The +.ul +global +command +.UL g +is used to execute one or more +.ul +ed +commands on all those lines in the buffer +that match some specified string. +For example +.P1 +g/peling/p +.P2 +prints all lines that contain +.UL peling . +More usefully, +.P1 +g/peling/s//pelling/gp +.P2 +makes the substitution everywhere on the line, +then prints each corrected line. +Compare this to +.P1 +1,$s/peling/pelling/gp +.P2 +which only prints the last line substituted. +Another subtle difference is that +the +.UL g +command +does not give a +.UL ? +if +.UL peling +is not found +where the +.UL s +command will. +.PP +There may be several commands +(including +.UL a , +.UL c , +.UL i , +.UL r , +.UL w , +but not +.UL g ); +in that case, +every line except the last must end with a backslash +.UL \e : +.P1 +g/xxx/\*.-1s/abc/def/\e +\&\*.+2s/ghi/jkl/\e +\&\*.-2,\*.p +.P2 +makes changes in the lines before and after each line +that contains +.UL xxx , +then prints all three lines. +.PP +The +.UL v +command is the same as +.UL g , +except that the commands are executed on every line +that does +.ul +not +match the string following +.UL v : +.P1 +v/ /d +.P2 +deletes every line that does not contain a blank. diff --git a/bin/ed/USD.doc/09.edtut/e6 b/bin/ed/USD.doc/09.edtut/e6 new file mode 100644 index 00000000000..4f488a46f38 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e6 @@ -0,0 +1,279 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e6 8.1 (Berkeley) 6/8/93 +.\" +.SH +Special Characters +.PP +You may have noticed that things just don't work right when you used +some characters like +\*., +.UL * , +.UL $ , +and others in +context searches and the substitute command. +The reason is rather complex, although the cure is simple. +Basically, +.ul +ed +treats these characters as special, with special meanings. +For instance, +.ul +in a context search or the first string of the substitute command only, +\*. +means ``any character,'' not a period, so +.P1 +/x\*.y/ +.P2 +means ``a line with an +.UL x , +.ul +any character, +and a +.UL y ,'' +.ul +not +just ``a line with an +.UL x , +a period, and a +.UL y .'' +A complete list of the special characters +that can cause trouble is the following: +.P1 +^ \*. $ [ * \e +.P2 +.ul +Warning: +The backslash character +.UL \e +is special to +.ul +ed. +For safety's sake, +avoid it where possible. +If you have to use one of the special characters +in a substitute command, +you can turn off its magic meaning temporarily +by preceding it with the backslash. +Thus +.P1 +s/\e\e\e\*.\e*/backslash dot star/ +.P2 +will change +.UL \e.* +into ``backslash dot star''. +.PP +Here is a hurried synopsis of the other special characters. +First, the circumflex +.UL ^ +signifies +the beginning of a line. +Thus +.P1 +/^string/ +.P2 +finds +.UL string +only if it is at the beginning of a line: +it will find +.P1 +string +.P2 +but not +.P1 +the string... +.P2 +The dollar-sign +.UL $ +is just the opposite of the circumflex; +it means the end of a line: +.P1 +/string$/ +.P2 +will only find an occurrence of +.UL string +that is at the end of some line. +This implies, of course, +that +.P1 +/^string$/ +.P2 +will find only a line that contains just +.UL string , +and +.P1 +/^\*.$/ +.P2 +finds a line containing exactly one character. +.PP +The character +.UL . , +as we mentioned above, +matches anything; +.P1 +/x\*.y/ +.P2 +matches any of +.P1 +x+y +x-y +x y +x\*.y +.P2 +This is useful in conjunction with +.UL * , +which is a repetition character; +.UL a* +is a shorthand for ``any number of +.UL a 's,'' +so +.UL .* +matches any number of anythings. +This is used like this: +.P1 +s/\*.*/stuff/ +.P2 +which changes an entire line, +or +.P1 +s/\*.*,// +.P2 +which deletes all characters in the line up to and +including the last comma. +(Since +.UL .* +finds the longest possible match, +this goes up to the last comma.) +.PP +.UL [ +is used with +.UL ] +to form ``character classes''; +for example, +.P1 +/[0123456789]/ +.P2 +matches any single digit \- +any one of the characters inside the braces +will cause a match. +This can be abbreviated to +.UL [0\-9] . +.PP +Finally, the +.UL & +is another shorthand character \- +it is used only on the right-hand part of a substitute command +where it means ``whatever was matched on the left-hand side''. +It is used to save typing. +Suppose the current line contained +.P1 +Now is the time +.P2 +and you wanted to put parentheses around it. +You could just retype the line, but +this is tedious. +Or you could say +.P1 +s/^/(/ +s/$/)/ +.P2 +using your knowledge of +.UL ^ +and +.UL $ . +But the easiest way uses the +.UL & : +.P1 +s/\*.*/(&)/ +.P2 +This says ``match the whole line, and replace it +by itself surrounded by parentheses.'' +The +.UL & +can be used several times in a line; +consider +using +.P1 +s/\*.*/&? &!!/ +.P2 +to produce +.P1 +Now is the time? Now is the time!! +.P2 +.PP +You don't have to match the whole line, of course: +if the buffer contains +.P1 +the end of the world +.P2 +you could type +.P1 +/world/s//& is at hand/ +.P2 +to produce +.P1 +the end of the world is at hand +.P2 +Observe this expression carefully, +for it illustrates how to take advantage of +.ul +ed +to save typing. +The string +.UL /world/ +found the desired line; +the shorthand +.UL // +found the same +word in the line; +and the +.UL & +saves you from typing it again. +.PP +The +.UL & +is a special character only within +the replacement text of a substitute command, +and has no special meaning elsewhere. +You can turn off the special meaning of +.UL & +by preceding it with a +.UL \e : +.P1 +s/ampersand/\e&/ +.P2 +will convert the word ``ampersand'' into the literal symbol +.UL & +in the current line. diff --git a/bin/ed/USD.doc/09.edtut/e7 b/bin/ed/USD.doc/09.edtut/e7 new file mode 100644 index 00000000000..29affc00fc7 --- /dev/null +++ b/bin/ed/USD.doc/09.edtut/e7 @@ -0,0 +1,227 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)e7 8.1 (Berkeley) 6/8/93 +.\" +.sp 2 +.SH +Summary of Commands and Line Numbers +.PP +The general form of +.ul +ed +commands is the command name, +perhaps preceded by one or two line numbers, and, +in the case of +.UL e , +.UL r , +and +.UL w , +followed by a file name. +Only one command is allowed per line, +but a +.UL p +command may follow any other command +(except for +.UL e , +.UL r , +.UL w +and +.UL q ). +.LP +.UL a : +Append, that is, +add lines to the buffer (at line dot, unless +a different line is specified). Appending continues until +\*. +is typed on a new line. +Dot is set to the last line appended. +.LP +.UL c : +Change the specified lines to the new text which follows. +The new lines are terminated by a +\*., +as with +.UL a . +If no lines are specified, +replace line dot. +Dot is set to last line changed. +.LP +.UL d : +Delete the lines specified. +If none are specified, delete line dot. +Dot is set to the first undeleted line, +unless +.UL $ +is deleted, +in which case dot is set to +.UL $ . +.LP +.UL e : +Edit new file. +Any previous +contents of the buffer are thrown away, +so issue a +.UL w +beforehand. +.LP +.UL f : +Print remembered filename. +If a name follows +.UL f +the remembered name will be set to it. +.LP +.UL g : +The command +.P1 +g/\(hy\(hy\(hy/commands +.P2 +will execute the commands on those lines that contain +.UL --- , +which can be any context search expression. +.LP +.UL i : +Insert lines before specified line (or dot) +until a +\*. +is typed on a new line. +Dot is set to last line inserted. +.LP +.UL m : +Move lines specified to after the line +named after +.UL m . +Dot is set to the last line moved. +.LP +.UL p : +Print specified lines. +If none specified, print +line dot. +A single line number is equivalent to +.IT line-number +.UL p . +A single return prints +.UL .+1 , +the next line. +.LP +.UL q : +Quit +.IT ed . +Wipes out all text in buffer +if you give it twice in a row without first giving a +.UL w +command. +.LP +.UL r : +Read a file into buffer (at end unless specified +elsewhere.) Dot set to last line read. +.LP +.UL s : +The command +.P1 +s/string1/string2/ +.P2 +substitutes the characters +.UL string1 +into +.UL string2 +in the specified lines. +If no lines are specified, make the substitution in line dot. +Dot is set to last line in which a +substitution took place, which means that if no substitution took place, dot is not changed. +.UL s +changes only the first occurrence of +.UL string1 +on a line; +to change all of them, type a +.UL g +after the final slash. +.LP +.UL v : +The command +.P1 +v/\(hy\(hy\(hy/commands +.P2 +executes +.UL commands +on those lines that +.ul +do not +contain +.UL --- . +.LP +.UL w : +Write out buffer onto a file. +Dot is not changed. +.LP +.UL .= : +Print value of dot. +.UL = "" ( +by itself prints the value of +.UL $ .) +.LP +.UL ! : +The line +.P1 +!command\(hyline +.P2 +causes +.UL command-line +to be executed as a +.UC UNIX +command. +.LP +.UL /-----/ : +Context search. +Search for next line which contains +this string of characters. +Print it. +Dot is set to the line where string +was found. +Search starts at +.UL .+1 , +wraps around from +.UL $ +to +1, +and continues to dot, if necessary. +.LP +.UL ?-----? : +Context search in reverse direction. +Start search +at +.UL .\-1 , +scan to 1, +wrap around to +.UL $ . diff --git a/bin/ed/USD.doc/10.edadv/Makefile b/bin/ed/USD.doc/10.edadv/Makefile new file mode 100644 index 00000000000..4783eae7e73 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2003/06/26 15:22:51 mickey Exp $ + +DIR= usd/10.edadv +SRCS= ae.mac ae0 ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae9 +MACROS= -ms + +.include <bsd.doc.mk> diff --git a/bin/ed/USD.doc/10.edadv/ae.mac b/bin/ed/USD.doc/10.edadv/ae.mac new file mode 100644 index 00000000000..57d4b144f80 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae.mac @@ -0,0 +1,87 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae.mac 8.1 (Berkeley) 8/14/93 +.\" +.tr _\(em +.de UL +.if n .ul +.if n \\$3\\$1\\$2 +.if t \\$3\f3\\$1\fP\\$2 +.. +.de IT +.if t \\$3\f2\\$1\fP\\$2 +.if n .ul +.if n \\$3\\$1\\$2 +.. +.de UI +\f3\\$1\fI\\$2\fR\\$3 +.. +.de P1 +.if n .ls 1 +.nf +.if n .ta 5 10 15 20 25 30 35 40 45 50 55 60 +.if t .ta .3i .6i .9i 1.2i 1.5i 1.8i +.tr -\- +.\" use first argument as indent if present +.if \\n(.$ .DS I \\$1 +.if !\\n(.$ .DS I 5 +.. +.de P2 +.DE +.tr -- +.if n .ls 2 +.. +.if t .ds BL \s6\|\v'.1m'\(sq\v'-.1m'\|\s0 +.if n .ds BL [] +.if t .ds m \(mi +.if n .ds m - +.if t .ds n \(no +.if n .ds n - +.if t .ds s \v'.41m'\s+4*\s-4\v'-.41m' +.if n .ds s * +.if t .ds S \(sl +.if n .ds S / +.if t .ds d \s+4\&.\&\s-4 +.if n .ds d \&.\& +.if t .ds a \z@@ +.if n .ds a @ +.if t .ds . \s+2\fB.\fP\s-2 +.if n .ds . . +.if t .ds e \z\e\h'1u'\e +.if n .ds e \e +.hy 14 +.\" 2=not last lines; 4= no -xx; 8=no xx- +.tr *\(** + diff --git a/bin/ed/USD.doc/10.edadv/ae0 b/bin/ed/USD.doc/10.edadv/ae0 new file mode 100644 index 00000000000..506534dbfe7 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae0 @@ -0,0 +1,99 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae0 8.1 (Berkeley) 8/14/93 +.\" +.nr P1 1 +.EH 'USD:10-%''Advanced Editing on \s-2UNIX\s+2' +.OH 'Advanced Editing on \s-2UNIX\s+2''USD:10-%' +.\" .....TM 76-1273-8 39199 39199-11 +.\".RP +.TL +Advanced Editing on \s-2UNIX\s+2 +.AU "MH 2C518" 6021 +Brian W. Kernighan +.AI +Murray Hill, NJ +.AU +(Updated for 4.3BSD by Mark Seiden) +.AB +This paper is meant to help +secretaries, typists and programmers +to make effective use of the +.UX +facilities +for preparing and editing text. +It provides explanations and examples of +.IP \(bu +special characters, line addressing and global commands in the editor +.UL ed ; +.IP \(bu +commands for ``cut and paste'' operations on files +and parts of files, +including the +.UL mv , +.UL cp , +.UL cat +and +.UL rm +commands, +and the +.UL r , +.UL w , +.UL m +and +.UL t +commands of the editor; +.IP \(bu +editing scripts and +editor-based programs like +.UL grep +and +.UL sed . +.PP +Although the treatment is aimed +at non-programmers, +new +UNIX +users +with any background +should find helpful hints +on how to get their jobs done +more easily. +.AE +.\" .CS 16 0 16 0 0 3 +.if n .ls 2 +.if t .2C +.nr PS 9 +.nr VS 11 diff --git a/bin/ed/USD.doc/10.edadv/ae1 b/bin/ed/USD.doc/10.edadv/ae1 new file mode 100644 index 00000000000..c29629151d9 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae1 @@ -0,0 +1,108 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae1 8.1 (Berkeley) 6/8/93 +.\" +.NH +INTRODUCTION +.PP +Although +.UX +provides remarkably effective tools for text editing, +that by itself is no guarantee +that everyone will automatically +make the most effective use of them. +In particular, people who are not computer specialists _ +typists, secretaries, casual users _ +often use the system less effectively than they might. +(There is a good argument that new users would better use their time +learning a display editor, like +.ul +vi, +or perhaps a version of +.ul +emacs, +like +.ul +jove, +rather than an editor as ignorant of display terminals as +.ul +ed.) +.PP +This document is intended as a sequel to +.ul +A Tutorial Introduction to the UNIX Text Editor +[1], +providing explanations and examples of how to edit using +.ul +ed +with less effort. +(You should also be familiar with the material in +.ul +UNIX For Beginners +[2].) +Further information on all commands discussed here can be found in +section 1 of the +.ul +The UNIX User's Manual +[3]. +.PP +Examples are based on observations +of users +and the difficulties they encounter. +Topics covered include special characters in searches and substitute commands, +line addressing, the global commands, +and line moving and copying. +There are also brief discussions of +effective use +of related tools, like those for file manipulation, +and those based on +.UL ed , +like +.UL grep +and +.UL sed . +.PP +A word of caution. +There is only one way to learn to use something, +and that is to +.ul +use +it. +Reading a description is no substitute +for trying something. +A paper like this one should +give you ideas about what to try, +but until you actually try something, +you will not learn it. diff --git a/bin/ed/USD.doc/10.edadv/ae2 b/bin/ed/USD.doc/10.edadv/ae2 new file mode 100644 index 00000000000..d8395c92cd8 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae2 @@ -0,0 +1,1051 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae2 8.1 (Berkeley) 6/8/93 +.\" +.NH +SPECIAL CHARACTERS +.PP +The editor +.UL ed +is the primary interface to the system +for many people, so +it is worthwhile to know +how to get the most out of +.UL ed +for the least effort. +.PP +The next few sections will discuss +shortcuts +and labor-saving devices. +Not all of these will be instantly useful +to any one person, of course, +but a few will be, +and the others should give you ideas to store +away for future use. +And as always, +until you try these things, +they will remain theoretical knowledge, +not something you have confidence in. +.SH +The List command `l' +.PP +.UL ed +provides two commands for printing the contents of the lines +you're editing. +Most people are familiar with +.UL p , +in combinations like +.P1 +1,$p +.P2 +to print all the lines you're editing, +or +.P1 +s/abc/def/p +.P2 +to change +`abc' +to +`def' +on the current line. +Less familiar is the +.ul +list +command +.UL l +(the letter `\fIl\|\fR'), +which gives slightly more information than +.UL p . +In particular, +.UL l +makes visible characters that are normally invisible, +such as tabs and backspaces. +If you list a line that contains some of these, +.UL l +will print each tab as +.UL \z\(mi> +and each backspace as +.UL \z\(mi< .\(dg +.FS +\(dg These composite characters are created by overstriking a minus +and a > or <, so they only appear as < or > on display terminals. +.FE +This makes it much easier to correct the sort of typing mistake +that inserts extra spaces adjacent to tabs, +or inserts a backspace followed by a space. +.PP +The +.UL l +command +also `folds' long lines for printing _ +any line that exceeds 72 characters is printed on multiple lines; +each printed line except the last is terminated by a backslash +.UL \*e , +so you can tell it was folded. +This is useful for printing long lines on short terminals. +.PP +Occasionally the +.UL l +command will print in a line a string of numbers preceded by a backslash, +such as \*e07 or \*e16. +These combinations are used to make visible characters that normally don't print, +like form feed or vertical tab or bell. +Each such combination is a single character. +When you see such characters, be wary _ +they may have surprising meanings when printed on some terminals. +Often their presence means that your finger slipped while you were typing; +you almost never want them. +.SH +The Substitute Command `s' +.PP +Most of the next few sections will be taken up with a discussion +of the +substitute +command +.UL s . +Since this is the command for changing the contents of individual +lines, +it probably has the most complexity of any +.UL ed +command, +and the most potential for effective use. +.PP +As the simplest place to begin, +recall the meaning of a trailing +.UL g +after a substitute command. +With +.P1 +s/this/that/ +.P2 +and +.P1 +s/this/that/g +.P2 +the +first +one replaces the +.ul +first +`this' on the line +with `that'. +If there is more than one `this' on the line, +the second form +with the trailing +.UL g +changes +.ul +all +of them. +.PP +Either form of the +.UL s +command can be followed by +.UL p +or +.UL l +to `print' or `list' (as described in the previous section) +the contents of the line: +.P1 +s/this/that/p +s/this/that/l +s/this/that/gp +s/this/that/gl +.P2 +are all legal, and mean slightly different things. +Make sure you know what the differences are. +.PP +Of course, any +.UL s +command can be preceded by one or two `line numbers' +to specify that the substitution is to take place +on a group of lines. +Thus +.P1 +1,$s/mispell/misspell/ +.P2 +changes the +.ul +first +occurrence of +`mispell' to `misspell' on every line of the file. +But +.P1 +1,$s/mispell/misspell/g +.P2 +changes +.ul +every +occurrence in every line +(and this is more likely to be what you wanted in this +particular case). +.PP +You should also notice that if you add a +.UL p +or +.UL l +to the end of any of these substitute commands, +only the last line that got changed will be printed, +not all the lines. +We will talk later about how to print all the lines +that were modified. +.SH +The Undo Command `u' +.PP +Occasionally you will make a substitution in a line, +only to realize too late that it was a ghastly mistake. +The `undo' command +.UL u +lets you `undo' the last substitution: +the last line that was substituted can be restored to +its previous state by typing the command +.P1 +u +.P2 +.SH +The Metacharacter `\*.' +.PP +As you have undoubtedly noticed +when you use +.UL ed , +certain characters have unexpected meanings +when they occur in the left side of a substitute command, +or in a search for a particular line. +In the next several sections, we will talk about +these special characters, +which are often called `metacharacters'. +.PP +The first one is the period `\*.'. +On the left side of a substitute command, +or in a search with `/.../', +`\*.' stands for +.ul +any +single character. +Thus the search +.P1 +/x\*.y/ +.P2 +finds any line where `x' and `y' occur separated by +a single character, as in +.P1 +x+y +x\-y +x\*(BLy +x\*.y +.P2 +and so on. +(We will use \*(BL to stand for a space whenever we need to +make it visible.) +.PP +Since `\*.' matches a single character, +that gives you a way to deal with funny characters +printed by +.UL l . +Suppose you have a line that, when printed with the +.UL l +command, appears as +.P1 + .... th\*e07is .... +.P2 +and you want to get rid of the +\*e07 +(which represents the bell character, by the way). +.PP +The most obvious solution is to try +.P1 +s/\*e07// +.P2 +but this will fail. (Try it.) +The brute force solution, which most people would now take, +is to re-type the entire line. +This is guaranteed, and is actually quite a reasonable tactic +if the line in question isn't too big, +but for a very long line, +re-typing is a bore. +This is where the metacharacter `\*.' comes in handy. +Since `\*e07' really represents a single character, +if we say +.P1 +s/th\*.is/this/ +.P2 +the job is done. +The `\*.' matches the mysterious character between the `h' and the `i', +.ul +whatever it is. +.PP +Bear in mind that since `\*.' matches any single character, +the command +.P1 +s/\*./,/ +.P2 +converts the first character on a line into a `,', +which very often is not what you intended. +.PP +As is true of many characters in +.UL ed , +the `\*.' has several meanings, depending +on its context. +This line shows all three: +.P1 +\&\*.s/\*./\*./ +.P2 +The first `\*.' is a line number, +the number of +the line we are editing, +which is called `line dot'. +(We will discuss line dot more in Section 3.) +The second `\*.' is a metacharacter +that matches any single character on that line. +The third `\*.' is the only one that really is +an honest literal period. +On the +.ul +right +side of a substitution, `\*.' +is not special. +If you apply this command to the line +.P1 +Now is the time\*. +.P2 +the result will +be +.P1 +\&\*.ow is the time\*. +.P2 +which is probably not what you intended. +.SH +The Backslash `\*e' +.PP +Since a period means `any character', +the question naturally arises of what to do +when you really want a period. +For example, how do you convert the line +.P1 +Now is the time\*. +.P2 +into +.P1 +Now is the time? +.P2 +The backslash `\*e' does the job. +A backslash turns off any special meaning that the next character +might have; in particular, +`\*e\*.' converts the `\*.' from a `match anything' +into a period, so +you can use it to replace +the period in +.P1 +Now is the time\*. +.P2 +like this: +.P1 +s/\*e\*./?/ +.P2 +The pair of characters `\*e\*.' is considered by +.UL ed +to be a single real period. +.PP +The backslash can also be used when searching for lines +that contain a special character. +Suppose you are looking for a line that contains +.P1 +\&\*.PP +.P2 +The search +.P1 +/\*.PP/ +.P2 +isn't adequate, for it will find +a line like +.P1 +THE APPLICATION OF ... +.P2 +because the `\*.' matches the letter `A'. +But if you say +.P1 +/\*e\*.PP/ +.P2 +you will find only lines that contain `\*.PP'. +.PP +The backslash can also be used to turn off special meanings for +characters other than `\*.'. +For example, consider finding a line that contains a backslash. +The search +.P1 +/\*e/ +.P2 +won't work, +because the `\*e' isn't a literal `\*e', but instead means that the second `/' +no longer \%delimits the search. +But by preceding a backslash with another one, +you can search for a literal backslash. +Thus +.P1 +/\*e\*e/ +.P2 +does work. +Similarly, you can search for a forward slash `/' with +.P1 +/\*e// +.P2 +The backslash turns off the meaning of the immediately following `/' so that +it doesn't terminate the /.../ construction prematurely. +.PP +As an exercise, before reading further, find two substitute commands each of which will +convert the line +.P1 +\*ex\*e\*.\*ey +.P2 +into the line +.P1 +\*ex\*ey +.P2 +.PP +Here are several solutions; +verify that each works as advertised. +.P1 +s/\*e\*e\*e\*.// +s/x\*.\*./x/ +s/\*.\*.y/y/ +.P2 +.PP +A couple of miscellaneous notes about +backslashes and special characters. +First, you can use any character to delimit the pieces +of an +.UL s +command: there is nothing sacred about slashes. +(But you must use slashes for context searching.) +For instance, in a line that contains a lot of slashes already, like +.P1 +//exec //sys.fort.go // etc... +.P2 +you could use a colon as the delimiter _ +to delete all the slashes, type +.P1 +s:/::g +.P2 +.PP +Second, if # and @ are your character erase and line kill characters, +you have to type \*e# and \*e@; +this is true whether you're talking to +.UL ed +or any other program. +.PP +When you are adding text with +.UL a +or +.UL i +or +.UL c , +backslash is not special, and you should only put in +one backslash for each one you really want. +.SH +The Dollar Sign `$' +.PP +The next metacharacter, the `$', stands for `the end of the line'. +As its most obvious use, suppose you have the line +.P1 +Now is the +.P2 +and you wish to add the word `time' to the end. +Use the $ like this: +.P1 +s/$/\*(BLtime/ +.P2 +to get +.P1 +Now is the time +.P2 +Notice that a space is needed before `time' in +the substitute command, +or you will get +.P1 +Now is thetime +.P2 +.PP +As another example, replace the second comma in +the following line with a period without altering the first: +.P1 +Now is the time, for all good men, +.P2 +The command needed is +.P1 +s/,$/\*./ +.P2 +The $ sign here provides context to make specific which comma we mean. +Without it, of course, the +.UL s +command would operate on the first comma to produce +.P1 +Now is the time\*. for all good men, +.P2 +.PP +As another example, to convert +.P1 +Now is the time\*. +.P2 +into +.P1 +Now is the time? +.P2 +as we did earlier, we can use +.P1 +s/\*.$/?/ +.P2 +.PP +Like `\*.', the `$' +has multiple meanings depending on context. +In the line +.P1 +$s/$/$/ +.P2 +the first `$' refers to the +last line of the file, +the second refers to the end of that line, +and the third is a literal dollar sign, +to be added to that line. +.SH +The Circumflex `^' +.PP +The circumflex (or hat or caret) +`^' stands for the beginning of the line. +For example, suppose you are looking for a line that begins +with `the'. +If you simply say +.P1 +/the/ +.P2 +you will in all likelihood find several lines that contain `the' in the middle before +arriving at the one you want. +But with +.P1 +/^the/ +.P2 +you narrow the context, and thus arrive at the desired one +more easily. +.PP +The other use of `^' is of course to enable you to insert +something at the beginning of a line: +.P1 +s/^/\*(BL/ +.P2 +places a space at the beginning of the current line. +.PP +Metacharacters can be combined. To search for a +line that contains +.ul +only +the characters +.P1 +\&\*.PP +.P2 +you can use the command +.P1 +/^\*e\*.PP$/ +.P2 +.SH +The Star `*' +.PP +Suppose you have a line that looks like this: +.P1 +\fItext \fR x y \fI text \fR +.P2 +where +.ul +text +stands +for lots of text, +and there are some indeterminate number of spaces between the +.UL x +and the +.UL y . +Suppose the job is to replace all the spaces between +.UL x +and +.UL y +by a single space. +The line is too long to retype, and there are too many spaces +to count. +What now? +.PP +This is where the metacharacter `*' +comes in handy. +A character followed by a star +stands for as many consecutive occurrences of that +character as possible. +To refer to all the spaces at once, say +.P1 +s/x\*(BL*y/x\*(BLy/ +.P2 +The construction +`\*(BL*' +means +`as many spaces as possible'. +Thus `x\*(BL*y' means `an x, as many spaces as possible, then a y'. +.PP +The star can be used with any character, not just space. +If the original example was instead +.P1 +\fItext \fR x--------y \fI text \fR +.P2 +then all `\-' signs can be replaced by a single space +with the command +.P1 +s/x-*y/x\*(BLy/ +.P2 +.PP +Finally, suppose that the line was +.P1 +\fItext \fR x\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.y \fI text \fR +.P2 +Can you see what trap lies in wait for the unwary? +If you blindly type +.P1 +s/x\*.*y/x\*(BLy/ +.P2 +what will happen? +The answer, naturally, is that it depends. +If there are no other x's or y's on the line, +then everything works, but it's blind luck, not good management. +Remember that `\*.' matches +.ul +any +single character? +Then `\*.*' matches as many single characters as possible, +and unless you're careful, it can eat up a lot more of the line +than you expected. +If the line was, for example, like this: +.P1 +\fItext \fRx\fI text \fR x\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.\*.y \fI text \fRy\fI text \fR +.P2 +then saying +.P1 +s/x\*.*y/x\*(BLy/ +.P2 +will take everything from the +.ul +first +`x' to the +.ul +last +`y', +which, in this example, is undoubtedly more than you wanted. +.PP +The solution, of course, is to turn off the special meaning of +`\*.' with +`\*e\*.': +.P1 +s/x\*e\*.*y/x\*(BLy/ +.P2 +Now everything works, for `\*e\*.*' means `as many +.ul +periods +as possible'. +.PP +There are times when the pattern `\*.*' is exactly what you want. +For example, to change +.P1 +Now is the time for all good men .... +.P2 +into +.P1 +Now is the time\*. +.P2 +use `\*.*' to eat up everything after the `for': +.P1 +s/\*(BLfor\*.*/\*./ +.P2 +.PP +There are a couple of additional pitfalls associated with `*' that you should be aware of. +Most notable is the fact that `as many as possible' means +.ul +zero +or more. +The fact that zero is a legitimate possibility is +sometimes rather surprising. +For example, if our line contained +.P1 +\fItext \fR xy \fI text \fR x y \fI text \fR +.P2 +and we said +.P1 +s/x\*(BL*y/x\*(BLy/ +.P2 +the +.ul +first +`xy' matches this pattern, for it consists of an `x', +zero spaces, and a `y'. +The result is that the substitute acts on the first `xy', +and does not touch the later one that actually contains some intervening spaces. +.PP +The way around this, if it matters, is to specify a pattern like +.P1 +/x\*(BL\*(BL*y/ +.P2 +which says `an x, a space, then as many more spaces as possible, then a y', +in other words, one or more spaces. +.PP +The other startling behavior of `*' is again related to the fact +that zero is a legitimate number of occurrences of something +followed by a star. The command +.P1 +s/x*/y/g +.P2 +when applied to the line +.P1 +abcdef +.P2 +produces +.P1 +yaybycydyeyfy +.P2 +which is almost certainly not what was intended. +The reason for this behavior is that zero is a legal number +of matches, +and there are no x's at the beginning of the line +(so that gets converted into a `y'), +nor between the `a' and the `b' +(so that gets converted into a `y'), nor ... +and so on. +Make sure you really want zero matches; +if not, in this case write +.P1 +s/xx*/y/g +.P2 +`xx*' is one or more x's. +.SH +The Brackets `[ ]' +.PP +Suppose that you want to delete any numbers +that appear +at the beginning of all lines of a file. +You might first think of trying a series of commands like +.P1 +1,$s/^1*// +1,$s/^2*// +1,$s/^3*// +.P2 +and so on, +but this is clearly going to take forever if the numbers are at all long. +Unless you want to repeat the commands over and over until +finally all numbers are gone, +you must get all the digits on one pass. +This is the purpose of the brackets [ and ]. +.PP +The construction +.P1 +[0123456789] +.P2 +matches any single digit _ +the whole thing is called a `character class'. +With a character class, the job is easy. +The pattern `[0123456789]*' matches zero or more digits (an entire number), so +.P1 +1,$s/^[0123456789]*// +.P2 +deletes all digits from the beginning of all lines. +.PP +Any characters can appear within a character class, +and just to confuse the issue there are essentially no special characters +inside the brackets; +even the backslash doesn't have a special meaning. +To search for special characters, for example, you can say +.P1 +/[\*.\*e$^[]/ +.P2 +Within [...], the `[' is not special. +To get a `]' into a character class, +make it the first character. +.PP +It's a nuisance to have to spell out the digits, +so you can abbreviate them as +[0\-9]; +similarly, [a\-z] stands for the lower case letters, +and +[A\-Z] for upper case. +.PP +As a final frill on character classes, you can specify a class +that means `none of the following characters'. +This is done by beginning the class with a `^': +.P1 +[^0-9] +.P2 +stands for `any character +.ul +except +a digit'. +Thus you might find the first line that doesn't begin with a tab or space +by a search like +.P1 +/^[^(space)(tab)]/ +.P2 +.PP +Within a character class, +the circumflex has a special meaning +only if it occurs at the beginning. +Just to convince yourself, verify that +.P1 +/^[^^]/ +.P2 +finds a line that doesn't begin with a circumflex. +.SH +The Ampersand `&' +.PP +The ampersand `&' is used primarily to save typing. +Suppose you have the line +.P1 +Now is the time +.P2 +and you want to make it +.P1 +Now is the best time +.P2 +Of course you can always say +.P1 +s/the/the best/ +.P2 +but it seems silly to have to repeat the `the'. +The `&' is used to eliminate the repetition. +On the +.ul +right +side of a substitute, the ampersand means `whatever +was just matched', so you can say +.P1 +s/the/& best/ +.P2 +and the `&' will stand for `the'. +Of course this isn't much of a saving if the thing +matched is just `the', but if it is something truly long or awful, +or if it is something like `.*' +which matches a lot of text, +you can save some tedious typing. +There is also much less chance of making a typing error +in the replacement text. +For example, to parenthesize a line, +regardless of its length, +.P1 +s/\*.*/(&)/ +.P2 +.PP +The ampersand can occur more than once on the right side: +.P1 +s/the/& best and & worst/ +.P2 +makes +.P1 +Now is the best and the worst time +.P2 +and +.P1 +s/\*.*/&? &!!/ +.P2 +converts the original line into +.P1 +Now is the time? Now is the time!! +.P2 +.PP +To get a literal ampersand, naturally the backslash is used to turn off the special meaning: +.P1 +s/ampersand/\*e&/ +.P2 +converts the word into the symbol. +Notice that `&' is not special on the left side +of a substitute, only on the +.ul +right +side. +.SH +Substituting Newlines +.PP +.UL ed +provides a facility for splitting a single line into two or more shorter lines by `substituting in a newline'. +As the simplest example, suppose a line has gotten unmanageably long +because of editing (or merely because it was unwisely typed). +If it looks like +.P1 +\fItext \fR xy \fI text \fR +.P2 +you can break it between the `x' and the `y' like this: +.P1 +s/xy/x\*e +y/ +.P2 +This is actually a single command, +although it is typed on two lines. +Bearing in mind that `\*e' turns off special meanings, +it seems relatively intuitive that a `\*e' at the end of +a line would make the newline there +no longer special. +.PP +You can in fact make a single line into several lines +with this same mechanism. +As a large example, consider underlining the word `very' +in a long line +by splitting `very' onto a separate line, +and preceding it by the +.UL roff +or +.UL nroff +formatting command `.ul'. +.P1 +\fItext \fR a very big \fI text \fR +.P2 +The command +.P1 +s/\*(BLvery\*(BL/\*e +\&.ul\*e +very\*e +/ +.P2 +converts the line into four shorter lines, +preceding the word `very' by the +line +`.ul', +and eliminating the spaces around the `very', +all at the same time. +.PP +When a newline is substituted +in, dot is left pointing at the last line created. +.PP +.SH +Joining Lines +.PP +Lines may also be joined together, +but this is done with the +.UL j +command +instead of +.UL s . +Given the lines +.P1 +Now is +\*(BLthe time +.P2 +and supposing that dot is set to the first of them, +then the command +.P1 +j +.P2 +joins them together. +No blanks are added, +which is why we carefully showed a blank +at the beginning of the second line. +.PP +All by itself, +a +.UL j +command +joins line dot to line dot+1, +but any contiguous set of lines can be joined. +Just specify the starting and ending line numbers. +For example, +.P1 +1,$jp +.P2 +joins all the lines into one big one +and prints it. +(More on line numbers in Section 3.) +.SH +Rearranging a Line with \*e( ... \*e) +.PP +(This section should be skipped on first reading.) +Recall that `&' is a shorthand that stands for whatever +was matched by the left side of an +.UL s +command. +In much the same way you can capture separate pieces +of what was matched; +the only difference is that you have to specify +on the left side just what pieces you're interested in. +.PP +Suppose, for instance, that +you have a file of lines that consist of names in the form +.P1 +Smith, A. B. +Jones, C. +.P2 +and so on, +and you want the initials to precede the name, as in +.P1 +A. B. Smith +C. Jones +.P2 +It is possible to do this with a series of editing commands, +but it is tedious and error-prone. +(It is instructive to figure out how it is done, though.) +.PP +The alternative +is to `tag' the pieces of the pattern (in this case, +the last name, and the initials), +and then rearrange the pieces. +On the left side of a substitution, +if part of the pattern is enclosed between +\*e( and \*e), +whatever matched that part is remembered, +and available for use on the right side. +On the right side, +the symbol `\*e1' refers to whatever +matched the first \*e(...\*e) pair, +`\*e2' to the second \*e(...\*e), +and so on. +.PP +The command +.P1 +1,$s/^\*e([^,]*\*e),\*(BL*\*e(\*.*\*e)/\*e2\*(BL\*e1/ +.P2 +although hard to read, does the job. +The first \*e(...\*e) matches the last name, +which is any string up to the comma; +this is referred to on the right side with `\*e1'. +The second \*e(...\*e) is whatever follows +the comma and any spaces, +and is referred to as `\*e2'. +.PP +Of course, with any editing sequence this complicated, +it's foolhardy to simply run it and hope. +The global commands +.UL g +and +.UL v +discussed in section 4 +provide a way for you to print exactly those +lines which were affected by the +substitute command, +and thus verify that it did what you wanted +in all cases. diff --git a/bin/ed/USD.doc/10.edadv/ae3 b/bin/ed/USD.doc/10.edadv/ae3 new file mode 100644 index 00000000000..dae271ec326 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae3 @@ -0,0 +1,504 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae3 8.1 (Berkeley) 6/8/93 +.\" +.NH +LINE ADDRESSING IN THE EDITOR +.PP +The next general area we will discuss is that of +line addressing in +.UL ed , +that is, how you specify what lines are to be +affected by editing commands. +We have already used constructions like +.P1 +1,$s/x/y/ +.P2 +to specify a change on all lines. +And most users are long since familiar with +using a single newline (or return) to print the next line, +and with +.P1 +/thing/ +.P2 +to find a line that contains `thing'. +Less familiar, surprisingly enough, is the +use of +.P1 +?thing? +.P2 +to scan +.ul +backwards +for the previous occurrence of `thing'. +This is especially handy when you realize that the thing +you want to operate on is back up the page from +where you are currently editing. +.PP +The slash and question mark are the only characters you can +use to delimit a context search, though you can use +essentially any character in a substitute command. +.SH +Address Arithmetic +.PP +The next step is to combine the line numbers +like `\*.', `$', `/.../' and `?...?' +with `+' and `\-'. +Thus +.P1 +$-1 +.P2 +is a command to print the next to last line of +the current file (that is, one line before line `$'). +For example, to recall how far you got in a previous editing session, +.P1 +$-5,$p +.P2 +prints the last six lines. +(Be sure you understand why it's six, not five.) +If there aren't six, of course, you'll get an error message. +.PP +As another example, +.P1 +\&\*.-3,\*.+3p +.P2 +prints from three lines before where you are now +(at line dot) +to three lines after, +thus giving you a bit of context. +By the way, the `+' can be omitted: +.P1 +\&\*.-3,\*.3p +.P2 +is absolutely identical in meaning. +.PP +Another area in which you can save typing effort +in specifying lines is to use `\-' and `+' as line numbers +by themselves. +.P1 +- +.P2 +by itself is a command to move back up one line in the file. +In fact, you can string several minus signs together to move +back up that many lines: +.P1 +--- +.P2 +moves up three lines, as does `\-3'. +Thus +.P1 +-3,+3p +.P2 +is also identical to the examples above. +.PP +Since `\-' is shorter than `\*.\-1', +constructions like +.P1 +-,\*.s/bad/good/ +.P2 +are useful. This changes `bad' to `good' on the previous line and +on the current line. +.PP +`+' and `\-' can be used in combination with searches using `/.../' and `?...?', +and with `$'. +The search +.P1 +/thing/-- +.P2 +finds the line containing `thing', and positions you +two lines before it. +.SH +Repeated Searches +.PP +Suppose you ask for the search +.P1 +/horrible thing/ +.P2 +and when the line is printed you discover that it +isn't the horrible thing that you wanted, +so it is necessary to repeat the search again. +You don't have to re-type the search, +for the construction +.P1 +// +.P2 +is a shorthand for `the previous thing that was searched for', +whatever it was. +This can be repeated as many times as necessary. +You can also go backwards: +.P1 +?? +.P2 +searches for the same thing, +but in the reverse direction. +.PP +Not only can you repeat the search, but you can +use `//' as the left side of a substitute command, +to mean +`the most recent pattern'. +.P1 +/horrible thing/ +.ft I + .... ed prints line with `horrible thing' ... +.ft R +s//good/p +.P2 +To go backwards and change a line, say +.P1 +??s//good/ +.P2 +Of course, you can still use the `&' on the right hand side of a substitute to stand for +whatever got matched: +.P1 +//s//&\*(BL&/p +.P2 +finds the next occurrence of whatever you searched for last, +replaces it by two copies of itself, +then prints the line just to verify that it worked. +.SH +Default Line Numbers and the Value of Dot +.PP +One of the most effective ways to speed up your editing +is always to know what lines will be affected +by a command if you don't specify the lines it is to act on, +and on what line you will be positioned (i.e., the value of dot) when a command finishes. +If you can edit without specifying unnecessary +line numbers, you can save a lot of typing. +.PP +As the most obvious example, if you issue a search command +like +.P1 +/thing/ +.P2 +you are left pointing at the next line that contains `thing'. +Then no address is required with commands like +.UL s +to make a substitution on that line, +or +.UL p +to print it, +or +.UL l +to list it, +or +.UL d +to delete it, +or +.UL a +to append text after it, +or +.UL c +to change it, +or +.UL i +to insert text before it. +.PP +What happens if there was no `thing'? +Then you are left right where you were _ +dot is unchanged. +This is also true if you were sitting +on the only `thing' when you issued the command. +The same rules hold for searches that use +`?...?'; the only difference is the direction +in which you search. +.PP +The delete command +.UL d +leaves dot pointing +at the line that followed the last deleted line. +When line `$' gets deleted, +however, +dot points at the +.ul +new +line `$'. +.PP +The line-changing commands +.UL a , +.UL c +and +.UL i +by default all affect the current line _ +if you give no line number with them, +.UL a +appends text after the current line, +.UL c +changes the current line, +and +.UL i +inserts text before the current line. +.PP +.UL a , +.UL c , +and +.UL i +behave identically in one respect _ +when you stop appending, changing or inserting, +dot points at the last line entered. +This is exactly what you want for typing and editing on the fly. +For example, you can say +.P1 +.ta 1.5i +a + ... text ... + ... botch ... (minor error) +\&\*. +s/botch/correct/ (fix botched line) +a + ... more text ... +.P2 +without specifying any line number for the substitute command or for +the second append command. +Or you can say +.P1 2 +.ta 1.5i +a + ... text ... + ... horrible botch ... (major error) +\&\*. +c (replace entire line) + ... fixed up line ... +.P2 +.PP +You should experiment to determine what happens if you add +.ul +no +lines with +.UL a , +.UL c +or +.UL i . +.PP +The +.UL r +command will read a file into the text being edited, +either at the end if you give no address, +or after the specified line if you do. +In either case, dot points at the last line read in. +Remember that you can even say +.UL 0r +to read a file in at the beginning of the text. +(You can also say +.UL 0a +or +.UL 1i +to start adding text at the beginning.) +.PP +The +.UL w +command writes out the entire file. +If you precede the command by one line number, +that line is written, +while if you precede it by two line numbers, +that range of lines is written. +The +.UL w +command does +.ul +not +change dot: +the current line remains the same, +regardless of what lines are written. +This is true even if you say something like +.P1 +/^\*e\*.AB/,/^\*e\*.AE/w abstract +.P2 +which involves a context search. +.PP +Since the +.UL w +command is so easy to use, +you should save what you are editing regularly +as you go along +just in case the system crashes, or in case you do something foolish, +like clobbering what you're editing. +.PP +The least intuitive behavior, in a sense, is that of the +.UL s +command. +The rule is simple _ +you are left sitting on the last line that got changed. +If there were no changes, then dot is unchanged. +.PP +To illustrate, +suppose that there are three lines in the buffer, and you are sitting on +the middle one: +.P1 +x1 +x2 +x3 +.P2 +Then the command +.P1 +\&-,+s/x/y/p +.P2 +prints the third line, which is the last one changed. +But if the three lines had been +.P1 +x1 +y2 +y3 +.P2 +and the same command had been issued while +dot pointed +at the second line, then the result +would be to change and print only the first line, +and that is where dot would be set. +.SH +Semicolon `;' +.PP +Searches with `/.../' and `?...?' start +at the current line and move +forward or backward respectively +until they either find the pattern or get back to the current line. +Sometimes this is not what is wanted. +Suppose, for example, that the buffer contains lines like this: +.P1 + \*. + \*. + \*. + ab + \*. + \*. + \*. + bc + \*. + \*. +.P2 +Starting at line 1, one would expect that the command +.P1 +/a/,/b/p +.P2 +prints all the lines from the `ab' to the `bc' inclusive. +Actually this is not what happens. +.ul +Both +searches +(for `a' and for `b') +start from the same point, and thus they both find the line +that contains `ab'. +The result is to print a single line. +Worse, if there had been a line with a `b' in it +before the `ab' line, then the print command +would be in error, since the second line number +would be less than the first, and it is illegal to +try to print lines in reverse order. +.PP +This is because the comma separator +for line numbers doesn't set dot as each address is processed; +each search starts from the same place. +In +.UL ed , +the semicolon `;' can be used just like comma, +with the single difference that use of a semicolon +forces dot to be set at that point +as the line numbers are being evaluated. +In effect, the semicolon `moves' dot. +Thus in our example above, the command +.P1 +/a/;/b/p +.P2 +prints the range of lines from `ab' to `bc', +because after the `a' is found, dot is set to that line, +and then `b' is searched for, starting beyond that line. +.PP +This property is most often useful in a very simple situation. +Suppose you want to find the +.ul +second +occurrence of `thing'. +You could say +.P1 +/thing/ +// +.P2 +but this prints the first occurrence as well as the second, +and is a nuisance when you know very well that it is only +the second one you're interested in. +The solution is to say +.P1 +/thing/;// +.P2 +This says to find the first occurrence of `thing', set dot to that line, then find the second +and print only that. +.PP +Closely related is searching for the second previous +occurrence of something, as in +.P1 +?something?;?? +.P2 +Printing the third or fourth or ... +in either direction is left as an exercise. +.PP +Finally, bear in mind that if you want to find the first occurrence of +something in a file, starting at an arbitrary place within the file, +it is not sufficient to say +.P1 +1;/thing/ +.P2 +because this fails if `thing' occurs on line 1. +But it is possible to say +.P1 +0;/thing/ +.P2 +(one of the few places where 0 is a legal line number), +for this starts the search at line 1. +.SH +Interrupting the Editor +.PP +As a final note on what dot gets set to, +you should be aware that if you hit the interrupt or delete +or rubout or break key +while +.UL ed +is doing a command, things are put back together again and your state +is restored as much as possible to what it was before the command +began. +Naturally, some changes are irrevocable _ +if you are reading or writing a file or making substitutions or deleting lines, these will be stopped +in some clean but unpredictable state in the middle +(which is why it is not usually wise to stop them). +Dot may or may not be changed. +.PP +Printing is more clear cut. +Dot is not changed until the printing is done. +Thus if you print until you see an interesting line, +then hit delete, you are +.ul +not +sitting on that line or even near it. +Dot is left where it was when the +.UL p +command was started. diff --git a/bin/ed/USD.doc/10.edadv/ae4 b/bin/ed/USD.doc/10.edadv/ae4 new file mode 100644 index 00000000000..052ee2fcb5d --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae4 @@ -0,0 +1,218 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae4 8.1 (Berkeley) 6/8/93 +.\" +.NH +GLOBAL COMMANDS +.PP +The global commands +.UL g +and +.UL v +are used to perform one or more editing commands on all lines that either +contain +.UL g ) ( +or don't contain +.UL v ) ( +a specified pattern. +.PP +As the simplest example, the command +.P1 +g/UNIX/p +.P2 +prints all lines that contain the word `UNIX'. +The pattern that goes between the slashes can be anything +that could be used in a line search or in a substitute command; +exactly the same rules and limitations apply. +.PP +As another example, then, +.P1 +g/^\*e\*./p +.P2 +prints all the formatting commands in a file (lines that begin with `\*.'). +.PP +The +.UL v +command is identical to +.UL g , +except that it operates on those line that do +.ul +not +contain an occurrence of the pattern. +(Don't look too hard for mnemonic significance to +the letter `v'.) +So +.P1 +v/^\*e\*./p +.P2 +prints all the lines that don't begin with `\*.' _ +the actual text lines. +.PP +The command that follows +.UL g +or +.UL v +can be anything: +.P1 +g/^\*e\*./d +.P2 +deletes all lines that begin with `\*.', +and +.P1 +g/^$/d +.P2 +deletes all empty lines. +.PP +Probably the most useful command that can follow a global is the +substitute command, for this can be used to make a change +and print each affected line for verification. +For example, we could change the word `Unix' to `UNIX' +everywhere, and verify that +it really worked, +with +.P1 +g/Unix/s//UNIX/gp +.P2 +Notice that we used `//' in the substitute command to mean +`the previous pattern', in this case, `Unix'. +The +.UL p +command is done on every line +that matches the pattern, +not just those on which a substitution took place. +.PP +The global command operates by making +two passes over the file. +On the first pass, all lines that match the pattern are marked. +On the second pass, each marked line in turn is examined, +dot is set to that line, and the command executed. +This means that it is possible for the command that follows a +.UL g +or +.UL v +to use addresses, set dot, and so on, quite freely. +.P1 +g/^\*e\*.PP/+ +.P2 +prints the line that follows each `.PP' command (the signal for +a new paragraph in some formatting packages). +Remember that `+' means `one line past dot'. +And +.P1 +g/topic/?^\*e\*.SH?1 +.P2 +searches for each line that contains `topic', scans backwards until it finds +a line that begins `.SH' (a section heading) and prints the line +that follows that, +thus showing the section headings under which `topic' is mentioned. +Finally, +.P1 +g/^\*e\*.EQ/+,/^\*e\*.EN/-p +.P2 +prints all the lines that lie between +lines beginning with `.EQ' and `.EN' formatting commands. +.PP +The +.UL g +and +.UL v +commands can also be +preceded by line numbers, in which case the lines searched +are only those in the range specified. +.SH +Multi-line Global Commands +.PP +It is possible to do more than one command under the control of a +global command, although the syntax for expressing the operation +is not especially natural or pleasant. +As an example, +suppose the task is to change `x' to `y' and `a' to `b' on all lines +that contain `thing'. +Then +.P1 +g/thing/s/x/y/\*e +s/a/b/ +.P2 +is sufficient. +The `\*e' signals the +.UL g +command that the set of commands continues on the next line; +it terminates on the first line that does not end with `\*e'. +(As a minor blemish, you can't use a substitute command +to insert a newline within a +.UL g +command.) +.PP +You should watch out for this problem: +the command +.P1 +g/x/s//y/\*e +s/a/b/ +.P2 +does +.ul +not +work as you expect. +The remembered pattern is the last pattern that was actually +executed, +so sometimes it will be +`x' (as expected), and sometimes it will be `a' +(not expected). +You must spell it out, like this: +.P1 +g/x/s/x/y/\*e +s/a/b/ +.P2 +.PP +It is also possible to execute +.UL a , +.UL c +and +.UL i +commands under a global command; as with other multi-line constructions, +all that is needed is to add a `\*e' at the end of each line except the last. +Thus to add a `.nf' and `.sp' command before each `.EQ' line, type +.P1 +g/^\*e\*.EQ/i\*e +\&\*.nf\*e +\&\*.sp +.P2 +There is no need for a final line containing a +`\*.' to terminate the +.UL i +command, +unless there are further commands +being done under the global. +On the other hand, it does no harm to put it in either. diff --git a/bin/ed/USD.doc/10.edadv/ae5 b/bin/ed/USD.doc/10.edadv/ae5 new file mode 100644 index 00000000000..7011ae21105 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae5 @@ -0,0 +1,359 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae5 8.1 (Berkeley) 8/14/93 +.\" +.NH +CUT AND PASTE WITH UNIX COMMANDS +.PP +One editing area in which non-programmers +seem not very confident +is in what might be called +`cut and paste' operations _ +changing the name of a file, +making a copy of a file somewhere else, +moving a few lines from one place to another in a file, +inserting one file in the middle of another, +splitting a file into pieces, +and +splicing two or more files together. +.PP +Yet most of these operations are actually quite easy, +if you keep your wits about you +and go cautiously. +The next several sections talk about cut and paste. +We will begin with the +.UX +commands +for moving entire files around, +then discuss +.UL ed +commands +for operating on pieces of files. +.SH +Changing the Name of a File +.PP +You have a file named +`memo' +and you want it to be called +`paper' +instead. +How is it done? +.PP +The +.UX +program that renames files +is called +.UL mv +(for `move'); +it `moves' the file from one name to another, like this: +.P1 +mv memo paper +.P2 +That's all there is to it: +.UL mv +from the old name to the new name. +.P1 +mv oldname newname +.P2 +Warning: if there is already a file around with the new name, +its present contents will be +silently +clobbered +by the information from the other file. +The one exception is that you can't move a file +to itself _ +.P1 +mv x x +.P2 +is illegal. +.SH +Making a Copy of a File +.PP +Sometimes what you want is a copy of a file _ +an entirely fresh version. +This might be because you want to work on a file, and +yet save a copy in case something gets fouled up, +or just because you're paranoid. +.PP +In any case, the way to do it is with the +.UL cp +command. +.UL cp \& ( +stands for `copy'; +the +UNIX +system +is big on short command names, +which are appreciated by heavy users, +but sometimes a strain for novices.) +Suppose you have a file called +`good' +and +you want to save a copy before you make some +dramatic editing changes. +Choose a name _ +`savegood' +might be acceptable _ then type +.P1 +cp good savegood +.P2 +This copies +`good' +onto +`savegood', +and you now have two identical copies of the file +`good'. +(If +`savegood' +previously contained something, +it gets overwritten.) +.PP +Now if you decide at some time that you want to get +back to the original state of +`good', +you can say +.P1 +mv savegood good +.P2 +(if you're not interested in +`savegood' +any more), or +.P1 +cp savegood good +.P2 +if you still want to retain a safe copy. +.PP +In summary, +.UL mv +just renames a file; +.UL cp +makes a duplicate copy. +Both of them clobber the `target' file +if it already exists, so you had better +be sure that's what you want to do +.ul +before +you do it. +.SH +Removing a File +.PP +If you decide you are really done with a file +forever, you can remove it +with the +.UL rm +command: +.P1 +rm savegood +.P2 +throws away (irrevocably) the file called +`savegood'. +.SH +Putting Two or More Files Together +.PP +The next step is the familiar one of collecting two or more +files into one big one. +This will be needed, for example, +when the author of a paper +decides that several sections need to be combined +into one. +There are several ways to do it, +of which the cleanest, once you get used to it, +is a program called +.UL cat . +(Not +.ul +all +UNIX +programs have two-letter names.) +.UL cat +is short for +`concatenate', which is exactly +what we want to do. +.PP +Suppose the job is to combine the files +`file1' +and +`file2' +into a single file called +`bigfile'. +If you say +.P1 +cat file +.P2 +the contents of +`file' +will get printed on your terminal. +If you say +.P1 +cat file1 file2 +.P2 +the contents of +`file1' +and then the contents of +`file2' +will +.ul +both +be printed on your terminal, +in that order. +So +.UL cat +combines the files, all right, +but it's not much help to print them on the terminal _ +we want them in +`bigfile'. +.PP +Fortunately, there is a way. +You can tell +the system +that instead of printing on your terminal, +you want the same information put in a file. +The way to do it is to add to the command line +the character +.UL > +and the name of the file +where you want the output to go. +Then you can say +.P1 +cat file1 file2 >bigfile +.P2 +and the job is done. +(As with +.UL cp +and +.UL mv , +you're putting something into +`bigfile', +and anything that was already there is destroyed.) +.PP +This ability to +`capture' the output of a program +is one of the most useful aspects of +the +UNIX +system. +Fortunately it's not limited to the +.UL cat +program _ +you can use it with +.ul +any +program that prints on your terminal. +We'll see some more uses for it in a moment. +.PP +Naturally, you can combine several files, +not just two: +.P1 +cat file1 file2 file3 ... >bigfile +.P2 +collects a whole bunch. +.PP +Question: +is there any difference between +.P1 +cp good savegood +.P2 +and +.P1 +cat good >savegood +.P2 +Answer: for most purposes, no. +You might reasonably ask why there are two programs +in that case, +since +.UL cat +is obviously all you need. +The answer is that +.UL cp +can do some other things as well, +which you can investigate for yourself +by reading the manual. +For now we'll stick to simple usages. +.SH +Adding Something to the End of a File +.PP +Sometimes you want to add one file to the end of another. +We have enough building blocks now that you can do it; +in fact before reading further it would be valuable +if you figured out how. +To be specific, +how would you use +.UL cp , +.UL mv +and/or +.UL cat +to add the file +`good1' +to the end of the file +`good'? +.PP +You could try +.P1 +cat good good1 >temp +mv temp good +.P2 +which is probably most direct. +You should also understand why +.P1 +cat good good1 >good +.P2 +doesn't work. +(Don't practice with a good `good'!) +.PP +The easy way is to use a variant of +.UL > , +called +.UL >> . +In fact, +.UL >> +is identical to +.UL > +except that instead of clobbering the old file, +it simply tacks stuff on at the end. +Thus you could say +.P1 +cat good1 >>good +.P2 +and +`good1' +is added to the end of +`good'. +(And if +`good' +didn't exist, +this makes a copy of +`good1' +called +`good'.) diff --git a/bin/ed/USD.doc/10.edadv/ae6 b/bin/ed/USD.doc/10.edadv/ae6 new file mode 100644 index 00000000000..4ea0f1763d1 --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae6 @@ -0,0 +1,528 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae6 8.1 (Berkeley) 6/8/93 +.\" +.NH +CUT AND PASTE WITH THE EDITOR +.PP +Now we move on to manipulating pieces of files _ +individual lines or groups of lines. +This is another area where new users seem +unsure of themselves. +.SH +Filenames +.PP +The first step is to ensure that you know the +.UL ed +commands for reading and writing files. +Of course you can't go very far without knowing +.UL r +and +.UL w . +Equally useful, but less well known, is the `edit' command +.UL e . +Within +.UL ed , +the command +.P1 +e newfile +.P2 +says `I want to edit a new file called +.ul +newfile, +without leaving the editor.' +The +.UL e +command discards whatever you're currently working on +and starts over on +.ul +newfile. +It's exactly the same as if you had quit with the +.UL q +command, then re-entered +.UL ed +with a new file name, +except that if you have a pattern remembered, then a command +like +.UL // +will still work. +.PP +If you enter +.UL ed +with the command +.P1 +ed file +.P2 +.UL ed +remembers the name of the file, +and any subsequent +.UL e , +.UL r +or +.UL w +commands that don't contain a filename +will refer to this remembered file. +Thus +.P1 2 +.ta .5i .6i .7i +ed file1 + ... (editing) ... +w (writes back in file1) +e file2 (edit new file, without leaving editor) + ... (editing on file2) ... +w (writes back on file2) +.P2 +(and so on) does a series of edits on various files +without ever leaving +.UL ed +and without typing the name of any file more than once. +(As an aside, if you examine the sequence of commands here, +you can see why many +UNIX +systems use +.UL e +as a synonym +for +.UL ed .) +.PP +You can find out the remembered file name at any time +with the +.UL f +command; +just type +.UL f +without a file name. +You can also change the name of the remembered file name with +.UL f ; +a useful sequence is +.P1 +ed precious +f junk + ... (editing) ... +.P2 +which gets a copy of a precious file, +then uses +.UL f +to guarantee that a careless +.UL w +command won't clobber the original. +.SH +Inserting One File into Another +.PP +Suppose you have a file called +`memo', +and you want the file called +`table' +to be inserted just after the reference to +Table 1. +That is, in +`memo' +somewhere is a line that says +.IP +Table 1 shows that ... +.LP +and the data contained in +`table' +has to go there, +probably so it will be formatted +properly by +.UL nroff +or +.UL troff . +Now what? +.PP +This one is easy. +Edit +`memo', +find +`Table 1', +and add the file +`table' +right there: +.P1 +ed memo +/Table 1/ +.ft I +Table 1 shows that ... [response from ed] +.ft +\&\*.r table +.P2 +The critical line is the last one. +As we said earlier, the +.UL r +command reads a file; +here you asked for it to be read in right after +line dot. +An +.UL r +command without any address +adds lines at the end, +so it is the same as +.UL $r . +.SH +Writing out Part of a File +.PP +The other side of the coin is writing out part of +the document you're editing. +For example, maybe +you want to copy out into a separate file +that table from the previous example, +so it can be formatted and tested separately. +Suppose that in the file being edited +we have +.P1 +\&\*.TS + ...[lots of stuff] +\&\*.TE +.P2 +which is the way a table is set up for the +.UL tbl +program. +To isolate +the table +in a separate file called +`table', +first find the start of the table +(the `.TS' line), then write out the interesting part: +.P1 +/^\*e\*.TS/ +.ft I +\&\*.TS [ed prints the line it found] +.ft R +\&\*.,/^\*e\*.TE/w table +.P2 +and the job is done. +If you are confident, you can do it all at once with +.P1 +/^\*e\*.TS/;/^\*e\*.TE/w table +.P2 +and now you have two copies, one in the file you're still editing, +one in the file `table' you've just written. +.PP +The point is that the +.UL w +command can +write out a group of lines, instead of the whole file. +In fact, you can write out a single line if you like; +just give one line number instead of two. +For example, if you have just typed a horribly complicated line +and you know that it (or something like it) is going to be needed later, +then save it _ don't re-type it. +In the editor, say +.P1 +a +\&...lots of stuff... +\&...horrible line... +\&\*. +\&\*.w temp +a +\&\*.\*.\*.more stuff\*.\*.\*. +\&\*. +\&\*.r temp +a +\&\*.\*.\*.more stuff\*.\*.\*. +\&\*. +.P2 +This last example is worth studying, to be sure you appreciate +what's going on. +.SH +Moving Lines Around +.PP +Suppose you want to +move a paragraph from its present position in a paper +to the end. +How would you do it? +As a concrete example, suppose each paragraph in the paper +begins with the formatting command +`.PP'. +Think about it and write down the details before reading on. +.PP +The brute force way +(not necessarily bad) +is to write the paragraph onto a temporary file, +delete it from its current position, +then read in the temporary file at the end. +Assuming that you are sitting on the +`.PP' command that begins +the paragraph, this is the sequence of commands: +.P1 +\&\*.,/^\*e\*.PP/-w temp +\&\*.,//-d +$r temp +.P2 +That is, from where you are now +(`\*.') +until one line before the next `\*.PP' +(`/^\*e\*.PP/\-') +write onto +`temp'. +Then delete the same lines. +Finally, read +`temp' +at the end. +.PP +As we said, that's the brute force way. +The easier way (often) +is to use the +.ul +move +command +.UL m +that +.UL ed +provides _ +it lets you do the whole set of operations +at one crack, +without any temporary file. +.PP +The +.UL m +command +is like many other +.UL ed +commands in that it takes up to two line numbers in front +that tell what lines are to be affected. +It is also +.ul +followed +by a line number that tells where the lines are to go. +Thus +.P1 +line1, line2 m line3 +.P2 +says to move all the lines between +`line1' +and +`line2' +after +`line3'. +Naturally, any of +`line1' +etc., can be patterns between slashes, +$ +signs, or other ways to specify lines. +.PP +Suppose again that you're sitting at the first line of the +paragraph. +Then you can say +.P1 +\&\*.,/^\*e\*.PP/-m$ +.P2 +That's all. +.PP +As another example of a frequent operation, +you can reverse the order of two adjacent lines +by moving the first one +to after the second. +Suppose that you are positioned at the first. +Then +.P1 +m+ +.P2 +does it. +It says to move line dot to after one line after line dot. +If you are positioned on the second line, +.P1 +m-- +.P2 +does the interchange. +.PP +As you can see, the +.UL m +command is more succinct and direct than +writing, deleting and re-reading. +When is brute force better anyway? +This is a matter of personal taste _ +do what you have most confidence in. +The main difficulty with the +.UL m +command +is that if you use patterns to specify both the lines +you are moving and the target, +you have to take care that you specify them properly, +or you may well not move the lines you thought you did. +The result of a botched +.UL m +command can be a ghastly mess. +Doing the job a step at a time +makes it easier for you to verify at each step +that you accomplished what you wanted to. +It's also a good idea to issue a +.UL w +command +before doing anything complicated; +then if you goof, it's easy to back up +to where you were. +.SH +Marks +.PP +.UL ed +provides a facility for marking a line +with a particular name so you can later reference it +by name +regardless of its actual line number. +This can be handy for moving lines, +and for keeping track of them even after they've been moved. +The +.ul +mark +command is +.UL k ; +the command +.P1 +kx +.P2 +marks the current line with the name `x'. +If a line number precedes the +.UL k , +that line is marked. +(The mark name must be a single lower case letter.) +Now you can refer to the marked line with the address +.P1 +\(fmx +.P2 +.PP +Marks are most useful for moving things around. +Find the first line of the block to be moved, and mark it +with +.ul +\(fma. +Then find the last line and mark it with +.ul +\(fmb. +Now position yourself at the place where the stuff is to go +and say +.P1 +\(fma,\(fmbm\*. +.P2 +.PP +Bear in mind that only one line can have a particular +mark name associated with it +at any given time. +.SH +Copying Lines +.PP +We mentioned earlier the idea of saving a line +that was hard to type or used often, +so as to cut down on typing time. +Of course this could be more than one line; +then the saving is presumably even greater. +.PP +.UL ed +provides another command, +called +.UL t +(for `transfer') +for making a copy of a group of one or more lines +at any point. +This is often easier than writing and reading. +.PP +The +.UL t +command is identical to the +.UL m +command, except that instead of moving lines +it simply duplicates them at the place you named. +Thus +.P1 +1,$t$ +.P2 +duplicates the entire contents that you are editing. +A more common use for +.UL t +is for creating a series of lines that differ only slightly. +For example, you can say +.P1 +.ta 1i +a +\&.......... x ......... (long line) +\&\*. +t\*. (make a copy) +s/x/y/ (change it a bit) +t\*. (make third copy) +s/y/z/ (change it a bit) +.P2 +and so on. +.SH +The Temporary Escape `!' +.PP +Sometimes it is convenient to be able +to temporarily escape from the editor to do +some other +.UX +command, +perhaps one of the file copy or move commands +discussed in section 5, +without leaving the editor. +The `escape' command +.UL ! +provides a way to do this. +.PP +If you say +.P1 +!any UNIX command +.P2 +your current editing state is suspended, +and the +.UX +command you asked for is executed. +When the command finishes, +.UL ed +will signal you by printing another +.UL ! ; +at that point you can resume editing. +.PP +You can really do +.ul +any +.UX +command, including another +.UL ed . +(This is quite common, in fact.) +In this case, you can even do another +.UL ! . +.PP +On Berkeley +.UX +systems, there is an additional (and preferable) mechanism called +.ul +job control +which lets you suspend your edit session (or, for that matter, +any program), return to the shell from +which you invoked that program, and issue any commands, then resume +the program from the point where it was stopped. See +.ul +An Introduction to the C Shell +for more details. diff --git a/bin/ed/USD.doc/10.edadv/ae7 b/bin/ed/USD.doc/10.edadv/ae7 new file mode 100644 index 00000000000..dcea27498fd --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae7 @@ -0,0 +1,220 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae7 8.1 (Berkeley) 6/8/93 +.\" +.NH +SUPPORTING TOOLS +.PP +There are several tools and techniques that go along with the +editor, all of which are relatively easy once you +know how +.UL ed +works, +because they are all based on the editor. +In this section we will give some fairly cursory examples +of these tools, +more to indicate their existence than to provide +a complete tutorial. +More information on each can be found in +[3]. +.SH +Grep +.PP +Sometimes you want to find all occurrences of some word or pattern in +a set of files, to edit them +or perhaps just to verify their presence or absence. +It may be possible to edit each file separately and look +for the pattern of interest, but if there are many files +this can get very tedious, +and if the files are really big, +it may be impossible because of limits in +.UL ed . +.PP +The program +.UL grep +was invented to get around these limitations. +The search patterns that we have described in the paper are often +called `regular expressions', and +`grep' stands for +.P1 +g/re/p +.P2 +That describes exactly what +.UL grep +does _ +it prints every line in a set of files that contains a +particular pattern. +Thus +.P1 +grep \(fmthing\(fm file1 file2 file3 ... +.P2 +finds `thing' wherever it occurs in any of the files +`file1', +`file2', +etc. +.UL grep +also indicates the file in which the line was found, +so you can later edit it if you like. +.PP +The pattern represented by `thing' can be any +pattern you can use in the editor, +since +.UL grep +and +.UL ed +use exactly the same mechanism for +pattern searching. +It is wisest always to enclose the pattern in the +single quotes \(fm...\(fm if it contains any non-alphabetic +characters, since many such characters also mean something +special to the +.UX +command interpreter +(the `shell'). +If you don't quote them, the command interpreter will +try to interpret them before +.UL grep +gets a chance. +.PP +There is also a way to find lines that +.ul +don't +contain a pattern: +.P1 +grep -v \(fmthing\(fm file1 file2 ... +.P2 +finds all lines that +don't contains `thing'. +The +.UL \-v +must occur in the position shown. +Given +.UL grep +and +.UL grep\ \-v , +it is possible to do things like selecting all lines that +contain some combination of patterns. +For example, to get all lines that contain `x' but not `y': +.P1 +grep x file... | grep -v y +.P2 +(The notation | is a `pipe', +which causes the output of the first command to be used as +input to the second command; see [2].) +.SH +Editing Scripts +.PP +If 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. +.PP +For 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 +.P1 +g/Unix/s//UNIX/g +g/Gcos/s//GCOS/g +w +q +.P2 +Now you can say +.P1 +ed file1 <script +ed file2 <script +\&... +.P2 +This causes +.UL ed +to take its commands from the prepared script. +Notice that the whole job has to be planned in advance. +.PP +And of course by using the +.UX +command interpreter, you can +cycle through a set of files +automatically, with varying degrees of ease. +.SH +Sed +.PP +.UL sed +(`stream editor') +is a version of the editor with restricted capabilities +but which is capable of processing unlimited amounts of input. +Basically +.UL sed +copies its input to its output, applying one or more +editing commands to each line of input. +.PP +As an example, suppose that we want to do the `Unix' to `UNIX' +part of the +example given above, +but without rewriting the files. +Then the command +.P1 +sed \(fms/Unix/UNIX/g\(fm file1 file2 ... +.P2 +applies 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 sed +in such a case is that it can be used +with input too large for +.UL ed +to handle. +All the output can be collected in one place, +either in a file or perhaps piped into another program. +.PP +If the editing transformation is so complicated +that +more 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, +.P1 +sed -f cmdfile input-files... +.P2 +.PP +.UL sed +has further capabilities, including conditional testing +and branching, which we cannot go into here, but which are +described in detail in +.ul +Sed \- A Non-interactive Text Editor. + diff --git a/bin/ed/USD.doc/10.edadv/ae9 b/bin/ed/USD.doc/10.edadv/ae9 new file mode 100644 index 00000000000..8f6242f268b --- /dev/null +++ b/bin/ed/USD.doc/10.edadv/ae9 @@ -0,0 +1,58 @@ +.\" $OpeBSD$ +.\" +.\" Copyright (C) Caldera International Inc. 2001-2002. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code and documentation must retain the above +.\" copyright notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed or owned by Caldera +.\" International, Inc. +.\" 4. Neither the name of Caldera International, Inc. nor the names of other +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, +.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" @(#)ae9 8.1 (Berkeley) 6/8/93 +.\" +.SH +Acknowledgement +.PP +I am grateful to Ted Dolotta +for his careful reading and valuable suggestions. +.SH +References +.IP [1] +Brian W. Kernighan, +.ul +A Tutorial Introduction to the UNIX Text Editor, +Bell Laboratories internal memorandum. +.IP [2] +Brian W. Kernighan, +.ul +UNIX For Beginners, +Bell Laboratories internal memorandum. +.IP [3] +Ken L. Thompson and Dennis M. Ritchie, +.ul +The UNIX Programmer's Manual. +Bell Laboratories. |