%!PS-Adobe-3.0 %%Creator: groff version 1.16.1 %%CreationDate: Sun Jul 7 02:29:38 2002 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic %%+ font Symbol %%DocumentSuppliedResources: procset grops 1.16 1 %%Pages: 10 %%PageOrder: Ascend %%Orientation: Portrait %%EndComments %%BeginProlog %%BeginResource: procset grops 1.16 1 /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }bind def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /FL{ currentgray exch setgray fill setgray }bind def /BL/fill load def /LW/setlinewidth load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne{def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def }bind def /PEND{ clear countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%IncludeResource: font Times-Roman %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic %%IncludeResource: font Symbol grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE /Times-Roman@0 ENC0/Times-Roman RE %%EndProlog %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF(-)0 12 Q/F1 12/Times-Bold@0 SF 3(AT)166.271 132 S(utorial Intr)-4.104 E(oduction to the)-.216 E/F2 10/Times-Bold@0 SF (UNIX)3 E F1 -1.104(Te)3 G(xt Editor)1.104 E/F3 10/Times-Italic@0 SF (B. W)255.025 168 Q 2.5(.K)-.92 G(ernighan)-2.85 E F0 (Bell Laboratories, Murray Hill, N. J.)214.815 198 Q/F4 9/Times-Bold@0 SF(Intr)72 245 Q(oduction)-.162 E/F5 9/Times-Italic@0 SF(Ed)94.5 259.3 Q /F6 9/Times-Roman@0 SF .968(is a `)3.218 F(`te)-.666 E .968(xt editor') -.135 F .968(', that is, an interacti)-.666 F 1.238 -.135(ve p)-.225 H (ro-).135 E 1.516(gram for creating and modifying `)72 270.3 R(`te)-.666 E(xt')-.135 E 1.516(', using direc-)-.666 F .241(tions pro)72 281.3 R .241(vided by a user at a terminal.)-.135 F .24(The te)4.74 F .24 (xt is often)-.135 F 2.798(ad)72 292.3 S .548(ocument lik)-2.798 F 2.798 (et)-.09 G .548(his one, or a program or perhaps data)-2.798 F (for a program.)72 303.3 Q 1.85 (This introduction is meant to simplify learning)94.5 317.6 R F5(ed.)72 328.6 Q F6 1.123(The recommended w)5.623 F 1.123(ay to learn)-.09 F F5 (ed)3.373 E F6 1.124(is to read this)3.373 F .282 (document, simultaneously using)72 339.6 R F5(ed)2.532 E F6 .281 (to follo)2.532 F 2.531(wt)-.225 G .281(he e)-2.531 F(xam-)-.135 E 1.938 (ples, then to read the description in section I of the)72 350.6 R 2.287 (UNIX manual, all the while e)72 361.6 R 2.287(xperimenting with)-.135 F F5(ed.)4.537 E F6 1.503(\(Solicitation of advice from e)72 372.6 R 1.503 (xperienced users is also)-.135 F(useful.\))72 383.6 Q .832(Do the e) 94.5 397.9 R -.135(xe)-.135 G 3.082(rcises! The).135 F 3.082(yc)-.135 G -.135(ove)-3.082 G 3.082(rm).135 G .832(aterial not com-)-3.082 F .657 (pletely discussed in the actual te)72 408.9 R 2.907(xt. An)-.135 F .657 (appendix sum-)2.907 F(marizes the commands.)72 419.9 Q F4(Disclaimer)72 441.9 Q F6 1.717(This is an introduction and a tutorial.)94.5 456.2 R -.135(Fo)6.216 G 3.966(rt).135 G(his)-3.966 E .31 (reason, no attempt is made to co)72 467.2 R -.135(ve)-.135 G 2.56(rm) .135 G .31(ore than a part of)-2.56 F 1.681(the f)72 478.2 R 1.681 (acilities that)-.09 F F5(ed)3.931 E F6(of)3.931 E 1.681 (fers \(although this fraction in-)-.225 F .829 (cludes the most useful and frequently used parts\).)72 489.2 R(Al-)5.33 E 1.641(so, there is not enough space to e)72 500.2 R 1.641 (xplain basic UNIX)-.135 F 2.755(procedures. W)72 511.2 R 2.755(ew)-.72 G .505(ill assume that you kno)-2.755 F 2.755(wh)-.225 G .955 -.225 (ow t)-2.755 H 2.755(ol).225 G(og)-2.755 E .715 (on to UNIX, and that you ha)72 522.2 R .985 -.135(ve a)-.18 H 2.965(tl) .135 G .715(east a v)-2.965 F .715(ague under)-.225 F(-)-.18 E (standing of what a \214le is.)72 533.2 Q -.99(Yo)94.5 547.5 S 2.372(um) .99 G .122(ust also kno)-2.372 F 2.372(ww)-.225 G .122 (hat character to type as the)-2.372 F .005 (end-of-line on your particular terminal.)72 558.5 R .004(This is a `) 4.504 F(`ne)-.666 E(w-)-.225 E(line')72 569.5 Q 4.126('o)-.666 G 4.126 (nM)-4.126 G 1.876(odel 37 T)-4.126 F 1.877(eletypes, and `)-.63 F (`return')-.666 E 4.127('o)-.666 G 4.127(nm)-4.127 G(ost)-4.127 E 4.858 (others. Throughout,)72 580.5 R 2.607(we will refer to this character) 4.858 F(,)-.36 E(whate)72 591.5 Q -.135(ve)-.225 G 2.25(ri).135 G 2.25 (ti)-2.25 G(s, as `)-2.25 E(`ne)-.666 E(wline')-.225 E('.)-.666 E F4 (Getting Started)72 613.5 Q F6 -.72(We)94.5 627.8 S -.09('l).72 G 3.531 (la).09 G 1.281(ssume that you ha)-3.531 F 1.551 -.135(ve l)-.18 H 1.282 (ogged in to UNIX).135 F .755(and it has just said `)72 638.8 R(`%') -.666 E 3.005('. The)-.666 F .754(easiest w)3.004 F .754(ay to get)-.09 F F5(ed)3.004 E F6(is)3.004 E(to type)72 649.8 Q 11.754(ed \(follo)93.6 664.8 R(wed by a ne)-.225 E(wline\))-.225 E -.99(Yo)72 679.8 S 2.768(ua) .99 G .518(re no)-2.768 F 2.768(wr)-.225 G .518(eady to go)-2.768 F/F7 9 /Symbol SF(-)2.768 E F5(ed)2.769 E F6 .519(is w)2.769 F .519 (aiting for you to tell)-.09 F(it what to do.)72 690.8 Q F4(Cr)302.4 245 Q(eating T)-.162 E(ext)-.828 E F7(-)2.25 E F4(the A)2.25 E (ppend command `)-.225 E(`a')-.567 E(')-.567 E F6 .934 (As our \214rst problem, suppose we w)324.9 259.3 R .933(ant to create) -.09 F .471(some te)302.4 270.3 R .471(xt starting from scratch.)-.135 F .472(Perhaps we are typing)4.971 F .008(the v)302.4 281.3 R .008 (ery \214rst draft of a paper; clearly it will ha)-.135 F .277 -.135 (ve t)-.18 H 2.257(os).135 G(tart)-2.257 E(some)302.4 292.3 Q .544 (where, and under)-.225 F .544(go modi\214cations later)-.162 F 5.045 (.T)-.495 G .545(his sec-)-5.045 F .286(tion will sho)302.4 303.3 R 2.536(wh)-.225 G .736 -.225(ow t)-2.536 H 2.536(og).225 G .286 (et some te)-2.536 F .285(xt in, just to get start-)-.135 F 2.25 (ed. Later)302.4 314.3 R(we')2.25 E(ll talk about ho)-.09 E 2.25(wt) -.225 G 2.25(oc)-2.25 G(hange it.)-2.25 E(When)324.9 328.6 Q F5(ed)3.061 E F6 .811(is \214rst started, it is rather lik)3.061 F 3.061(ew)-.09 G (orking)-3.151 E .752(with a blank piece of paper)302.4 339.6 R F7(-) 3.002 E F6 .751(there is no te)3.001 F .751(xt or infor)-.135 F(-)-.18 E 1.451(mation present.)302.4 350.6 R 1.451 (This must be supplied by the person)5.951 F(using)302.4 361.6 Q F5(ed;) 2.832 E F6 .582(it is usually done by typing in the te)2.832 F .582 (xt, or by)-.135 F .194(reading it into)302.4 372.6 R F5(ed)2.444 E F6 .194(from a \214le.)2.444 F 1.634 -.72(We w)4.694 H .195 (ill start by typing in).72 F(some te)302.4 383.6 Q (xt, and return shortly to ho)-.135 E 2.25(wt)-.225 G 2.25(or)-2.25 G (ead \214les.)-2.25 E .888(First a bit of terminology)324.9 397.9 R 5.388(.I)-.585 G(n)-5.388 E F5(ed)3.138 E F6(jar)3.138 E .888 (gon, the te)-.162 F(xt)-.135 E .138(being w)302.4 408.9 R(ork)-.09 E .138(ed on is said to be `)-.09 F(`k)-.666 E .139(ept in a b)-.09 F(uf) -.18 E(fer)-.225 E -.63(.')-.495 G 4.639('T)-.036 G(hink)-4.639 E .686 (of the b)302.4 419.9 R(uf)-.18 E .686(fer as a w)-.225 F .685 (ork space, if you lik)-.09 F .685(e, or simply as)-.09 F .462 (the information that you are going to be editing.)302.4 430.9 R .463 (In ef-)4.963 F .956(fect the b)302.4 441.9 R(uf)-.18 E .956(fer is lik) -.225 F 3.206(et)-.09 G .956(he piece of paper)-3.206 F 3.205(,o)-.36 G 3.205(nw)-3.205 G .955(hich we)-3.205 F .096 (will write things, then change some of them, and \214nally)302.4 452.9 R(\214le the whole thing a)302.4 463.9 Q -.09(wa)-.135 G 2.25(yf).09 G (or another day)-2.25 E(.)-.585 E .5(The user tells)324.9 478.2 R F5(ed) 2.749 E F6 .499(what to do to his te)2.749 F .499(xt by typing)-.135 F 4.52(instructions called `)302.4 489.2 R(`commands.)-.666 E 8.102 -.666 ('' M)-.63 H 4.521(ost commands).666 F .546(consist of a single letter) 302.4 500.2 R 2.795(,w)-.36 G .545(hich must be typed in lo)-2.795 F (wer)-.225 E 5.486(case. Each)302.4 511.2 R 3.237 (command is typed on a separate line.)5.486 F 1.437 (\(Sometimes the command is preceded by information)302.4 522.2 R .63 (about what line or lines of te)302.4 533.2 R .631(xt are to be af)-.135 F(fected)-.225 E F7(-)2.881 E F6(we)2.881 E 1.599 (will discuss these shortly)302.4 544.2 R(.\))-.585 E F5(Ed)6.099 E F6 (mak)3.849 E 1.598(es no response to)-.09 F 1.268(most commands)302.4 555.2 R F7(-)3.518 E F6 1.268(there is no prompting or typing of)3.518 F 1.619(messages lik)302.4 566.2 R 3.869(e`)-.09 G(`ready')-4.535 E 3.869 ('. \(This)-.666 F 1.618(silence is preferred by)3.869 F -.135(ex)302.4 577.2 S 1.155(perienced users, b).135 F 1.156 (ut sometimes a hangup for be)-.18 F(gin-)-.135 E(ners.\))302.4 588.2 Q .046(The \214rst command is)324.9 602.5 R F5(append,)2.296 E F6 .046 (written as the letter)2.296 F(a)324 617.5 Q .153(all by itself.)302.4 632.5 R .153(It means `)4.653 F .153(`append \(or add\) te)-.666 F .153 (xt lines to the)-.135 F -.18(bu)302.4 643.5 S -.225(ff).18 G(er).225 E 4.171(,a)-.36 G 4.171(sIt)-4.171 G 1.921(ype them in.)-4.171 F 5.503 -.666('' A)-.63 H 1.921(ppending is rather lik).666 F(e)-.09 E (writing fresh material on a piece of paper)302.4 654.5 Q(.)-.495 E 1.226(So to enter lines of te)324.9 668.8 R 1.227(xt into the b)-.135 F (uf)-.18 E(fer)-.225 E 3.477(,w)-.36 G 3.477(ej)-3.477 G(ust)-3.477 E 1.739(type an `)302.4 679.8 R(`a')-.666 E 3.989('f)-.666 G(ollo)-3.989 E 1.739(wed by a ne)-.225 F 1.739(wline, follo)-.225 F 1.739(wed by the) -.225 F(lines of te)302.4 690.8 Q(xt we w)-.135 E(ant, lik)-.09 E 2.25 (et)-.09 G(his:)-2.25 E(a)324 705.8 Q(No)324 716.8 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time)-2.25 E(for all good men)324 727.8 Q EP %%Page: 2 2 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF<89>0 11 Q 2.25<893289>279 58 S (to come to the aid of their party)93.6 105 Q(.)-.585 E/F1 9 /Times-Bold@0 SF(.)93.6 116 Q F0 .62(The only w)94.5 134.3 R .62 (ay to stop appending is to type a line)-.09 F .86 (that contains only a period.)72 145.3 R .86(The `)5.36 F(`)-.666 E F1 (.)A F0 2.192 -.666('' i)D 3.11(su).666 G .86(sed to tell)-3.11 F/F2 9 /Times-Italic@0 SF(ed)3.109 E F0 2.038(that we ha)72 156.3 R 2.308 -.135 (ve \214)-.18 H 2.039(nished appending.).135 F(\(Ev)6.539 E 2.039(en e) -.135 F(xperienced)-.135 E 2.626(users for)72 167.3 R 2.626 (get that terminating `)-.162 F(`)-.666 E F1(.)A F0 6.207 -.666('' s)D 4.875(ometimes. If).666 F F2(ed)4.875 E F0 1.1 (seems to be ignoring you, type an e)72 178.3 R 1.1(xtra line with just) -.135 F -.666(``)72 189.3 S F1(.).666 E F0 4.169 -.666('' o)D 5.087(ni) .666 G 5.087(t. Y)-5.087 F 2.837(ou may then \214nd you')-.99 F 3.107 -.135(ve a)-.45 H 2.837(dded some).135 F -.045(ga)72 200.3 S .105 (rbage lines to your te).045 F .105(xt, which you')-.135 F .105(ll ha) -.09 F .376 -.135(ve t)-.18 H 2.356(ot).135 G(ak)-2.356 E 2.356(eo)-.09 G(ut)-2.356 E(later)72 211.3 Q(.\))-.495 E 1.734 (After the append command has been done, the)94.5 225.6 R -.18(bu)72 236.6 S -.225(ff).18 G(er will contain the three lines).225 E(No)93.6 251.6 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time)-2.25 E (for all good men)93.6 262.6 Q(to come to the aid of their party)93.6 273.6 Q(.)-.585 E .153(The `)72 288.6 R(`a')-.666 E 2.403('a)-.666 G .153(nd `)-2.403 F(`)-.666 E F1(.)A F0 1.485 -.666('' a)D(ren').666 E 2.403(tt)-.162 G .153(here, because the)-2.403 F 2.403(ya)-.135 G .153 (re not te)-2.403 F(xt.)-.135 E 1.446 -.72(To a)94.5 302.9 T .006 (dd more te).72 F .005(xt to what we already ha)-.135 F -.135(ve)-.18 G 2.255(,j).135 G .005(ust is-)-2.255 F(sue another `)72 313.9 Q(`a')-.666 E 2.25('c)-.666 G(ommand, and continue typing.)-2.25 E F1(Err)72 335.9 Q (or Messages)-.162 E/F3 9/Symbol SF(-)2.25 E F1 -.567(``)2.25 G(?').567 E(')-.567 E F0 1.986(If at an)94.5 350.2 R 4.236(yt)-.135 G 1.986 (ime you mak)-4.236 F 4.236(ea)-.09 G 4.236(ne)-4.236 G 1.987 (rror in the com-)-4.236 F(mands you type to)72 361.2 Q F2(ed,)2.25 E F0 (it will tell you by typing)2.25 E(?)93.6 376.2 Q .778 (This is about as cryptic as it can be, b)72 391.2 R .778 (ut with practice,)-.18 F(you can usually \214gure out ho)72 402.2 Q 2.25(wy)-.225 G(ou goofed.)-2.25 E F1(Writing text out as a \214le)72 424.2 Q F3(-)2.25 E F1(the Write command `)2.25 E(`w')-.567 E(')-.567 E F0(It')94.5 438.5 Q 2.334(sl)-.495 G(ik)-2.334 E .084(ely that we')-.09 F .084(ll w)-.09 F .085(ant to sa)-.09 F .355 -.135(ve o)-.18 H .085 (ur te).135 F .085(xt for later)-.135 F 2.819(use. T)72 449.5 R 2.819 (ow)-.72 G .569(rite out the contents of the b)-2.819 F(uf)-.18 E .568 (fer onto a \214le,)-.225 F(we use the)72 460.5 Q F2(write)2.25 E F0 (command)2.25 E(w)93.6 475.5 Q(follo)72 490.5 Q 1.743 (wed by the \214lename we w)-.225 F 1.743(ant to write on.)-.09 F(This) 6.243 E 1.64(will cop)72 501.5 R 3.889(yt)-.09 G 1.639(he b)-3.889 F(uf) -.18 E(fer')-.225 E 3.889(sc)-.495 G 1.639 (ontents onto the speci\214ed \214le)-3.889 F(\(destro)72 512.5 Q 1.505 (ying an)-.09 F 3.755(yp)-.135 G(re)-3.755 E 1.506 (vious information on the \214le\).)-.225 F -.72(To)6.006 G(sa)72 523.5 Q .27 -.135(ve t)-.18 H(he te).135 E(xt on a \214le named `)-.135 E (`junk')-.666 E(', for e)-.666 E(xample, type)-.135 E 2.25(wj)93.6 538.5 S(unk)-2.25 E(Lea)72 553.5 Q .551 -.135(ve a s)-.18 H .281 (pace between `).135 F(`w')-.666 E 2.531('a)-.666 G .281 (nd the \214le name.)-2.531 F F2(Ed)4.78 E F0(will)2.53 E 1.205 (respond by printing the number of characters it wrote)72 564.5 R 2.25 (out. In)72 575.5 R(our case,)2.25 E F2(ed)2.25 E F0 -.09(wo)2.25 G (uld respond with).09 E(68)93.6 590.5 Q .172 (\(Remember that blanks and the ne)72 605.5 R .172 (wline character at the)-.225 F 1.407 (end of each line are included in the character count.\))72 616.5 R 2.568(Writing a \214le just mak)72 627.5 R 2.568(es a cop)-.09 F 4.817 (yo)-.09 G 4.817(ft)-4.817 G 2.567(he te)-4.817 F(xt)-.135 E F3(-)4.817 E F0(the)4.817 E -.18(bu)72 638.5 S -.225(ff).18 G(er').225 E 4.088(sc) -.495 G 1.838(ontents are not disturbed, so we can go on)-4.088 F .441 (adding lines to it.)72 649.5 R .44(This is an important point.)4.94 F F2(Ed)4.94 E F0 .44(at all)2.69 F .837(times w)72 660.5 R .837 (orks on a cop)-.09 F 3.087(yo)-.09 G 3.087(fa\214)-3.087 G .837 (le, not the \214le itself.)-3.087 F(No)5.337 E 1.522 (change in the contents of a \214le tak)72 671.5 R 1.522 (es place until you)-.09 F(gi)72 682.5 Q .715 -.135(ve a `)-.225 H(`w') -.531 E 2.695('c)-.666 G 2.695(ommand. \(Writing)-2.695 F .446 (out the te)2.695 F .446(xt onto a \214le)-.135 F .698 (from time to time as it is being created is a good idea,)72 693.5 R .723(since if the system crashes or if you mak)72 704.5 R 2.973(es)-.09 G .723(ome horri-)-2.973 F .857(ble mistak)72 715.5 R .857 (e, you will lose all the te)-.09 F .856(xt in the b)-.135 F(uf)-.18 E .856(fer b)-.225 F(ut)-.18 E(an)72 726.5 Q 2.25(yt)-.135 G -.135(ex) -2.25 G 2.25(tt).135 G(hat w)-2.25 E(as written onto a \214le is relati) -.09 E -.135(ve)-.225 G(ly safe.\)).135 E F1(Lea)302.4 105 Q(ving ed) -.225 E F3(-)2.25 E F1(the Quit command `)2.25 E(`q')-.567 E(')-.567 E F0 4.07 -.72(To t)324.9 119.3 T 2.63(erminate a session with).72 F F2 (ed,)4.88 E F0(sa)4.88 E 2.901 -.135(ve t)-.18 H 2.631(he te).135 F(xt) -.135 E(you')302.4 130.3 Q 1.515(re w)-.45 F 1.515 (orking on by writing it onto a \214le using the)-.09 F -.666(``)302.4 141.3 S(w').666 E 2.25('c)-.666 G(ommand, and then type the command) -2.25 E(q)324 156.3 Q 1.576(which stands for)302.4 171.3 R F2(quit.) 3.826 E F0 1.576(The system will respond with)6.076 F -.666(``)302.4 182.3 S(%').666 E 3.759('. At)-.666 F 1.509(this point your b)3.759 F (uf)-.18 E 1.509(fer v)-.225 F 1.509(anishes, with all its)-.225 F(te) 302.4 193.3 Q .444(xt, which is wh)-.135 F 2.694(yy)-.045 G .444(ou w) -2.694 F .444(ant to write it out before quit-)-.09 F(ting.)302.4 204.3 Q F1(Exer)302.4 226.3 Q(cise 1:)-.162 E F0(Enter)324.9 240.6 Q F2(ed) 2.25 E F0(and create some te)2.25 E(xt using)-.135 E(a)324 255.6 Q 2.25 (...t)324 266.6 S -.135(ex)-2.25 G 2.25(t...).135 G F1(.)324 277.6 Q F0 1.313(Write it out using `)302.4 292.6 R(`w')-.666 E 3.562('. Then)-.666 F(lea)3.562 E -.135(ve)-.18 G F2(ed)3.697 E F0 1.312(with the `)3.562 F (`q')-.666 E(')-.666 E 2.622 (command, and print the \214le, to see that e)302.4 303.6 R -.135(ve) -.225 G(rything).135 E -.09(wo)302.4 314.6 S(rk).09 E 2.25(ed. \(T)-.09 F 2.25(op)-.72 G(rint a \214le, say)-2.25 E(pr \214lename)324 329.6 Q (or)302.4 344.6 Q(cat \214lename)324 359.6 Q(in response to `)302.4 374.6 Q(`%')-.666 E 2.25('. T)-.666 F(ry both.\))-.315 E F1 (Reading text fr)302.4 396.6 Q(om a \214le)-.162 E F3(-)2.25 E F1 (the Edit command `)2.25 E(`e')-.567 E(')-.567 E F0 3.525(Ac)324.9 410.9 S 1.275(ommon w)-3.525 F 1.275(ay to get te)-.09 F 1.274(xt into the b) -.135 F(uf)-.18 E 1.274(fer is to)-.225 F .759 (read it from a \214le in the \214le system.)302.4 421.9 R .759 (This is what you)5.259 F .014(do to edit te)302.4 432.9 R .014 (xt that you sa)-.135 F -.135(ve)-.18 G 2.264(dw).135 G .014(ith the `) -2.264 F(`w')-.666 E 2.264('c)-.666 G .013(ommand in)-2.264 F 2.775(ap) 302.4 443.9 S(re)-2.775 E .525(vious session.)-.225 F(The)5.025 E F2 (edit)2.775 E F0 .526(command `)2.775 F(`e')-.666 E 2.776('f)-.666 G .526(etches the)-2.776 F 1.299(entire contents of a \214le into the b) 302.4 454.9 R(uf)-.18 E(fer)-.225 E 5.798(.S)-.495 G 3.548(oi)-5.798 G 3.548(fw)-3.548 G 3.548(eh)-3.548 G(ad)-3.548 E(sa)302.4 465.9 Q -.135 (ve)-.18 G 3.726(dt).135 G 1.476(he three lines `)-3.726 F(`No)-.666 E 3.726(wi)-.225 G 3.726(st)-3.726 G 1.476(he time')-3.726 F 1.476 (', etc., with a)-.666 F -.666(``)302.4 476.9 S(w').666 E 2.25('c)-.666 G(ommand in an earlier session, the)-2.25 E F2(ed)2.25 E F0(command)2.25 E 2.25(ej)324 491.9 S(unk)-2.25 E -.09(wo)302.4 506.9 S .978 (uld fetch the entire contents of the \214le `).09 F(`junk')-.666 E 3.228('i)-.666 G(nto)-3.228 E(the b)302.4 517.9 Q(uf)-.18 E(fer)-.225 E 2.25(,a)-.36 G(nd respond)-2.25 E(68)324 532.9 Q 1.248 (which is the number of characters in `)302.4 547.9 R(`junk')-.666 E('.) -.666 E F2 1.248(If any-)5.748 F(thing was alr)302.4 558.9 Q (eady in the b)-.333 E(uf)-.18 E(fer)-.162 E 2.25(,i)-.999 G 2.25(ti) -2.25 G 2.25(sd)-2.25 G(eleted \214r)-2.25 E(st.)-.09 E F0 .157 (If we use the `)324.9 573.2 R(`e')-.666 E 2.407('c)-.666 G .157 (ommand to read a \214le into the)-2.407 F -.18(bu)302.4 584.2 S -.225 (ff).18 G(er).225 E 3.015(,t)-.36 G .766 (hen we need not use a \214le name after a subse-)-3.015 F .684(quent `) 302.4 595.2 R(`w')-.666 E 2.934('c)-.666 G(ommand;)-2.934 E F2(ed)2.934 E F0 .684(remembers the last \214le name)2.934 F 1.005(used in an `) 302.4 606.2 R(`e')-.666 E 3.255('c)-.666 G 1.005(ommand, and `)-3.255 F (`w')-.666 E 3.255('w)-.666 G 1.006(ill write on this)-3.255 F 2.25 (\214le. Thus)302.4 617.2 R 2.25(ac)2.25 G(ommon w)-2.25 E (ay to operate is)-.09 E(ed)324 632.2 Q 2.25<658c>324 643.2 S(le)-2.25 E ([editing session])324 654.2 Q(w)324 665.2 Q(q)324 676.2 Q -.99(Yo)324.9 694.5 S 2.568(uc).99 G .318(an \214nd out at an)-2.568 F 2.567(yt)-.135 G .317(ime what \214le name)-2.567 F F2(ed)2.567 E F0(is)2.567 E .996 (remembering by typing the)302.4 705.5 R F2(\214le)3.247 E F0 .997 (command `)3.247 F -1.755(`f ')-.666 F 3.247('. In)-.666 F(our)3.247 E (case, if we typed)302.4 716.5 Q EP %%Page: 3 3 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893389>279 58 S(f)93.6 105 Q/F1 9 /Times-Italic@0 SF(ed)72 120 Q F0 -.09(wo)2.25 G(uld reply).09 E(junk) 93.6 135 Q/F2 9/Times-Bold@0 SF(Reading text fr)72 161 Q(om a \214le) -.162 E/F3 9/Symbol SF(-)2.25 E F2(the Read command `)2.25 E(`r')-.567 E (')-.567 E F0 .708(Sometimes we w)94.5 175.3 R .708 (ant to read a \214le into the b)-.09 F(uf)-.18 E(fer)-.225 E .655 (without destro)72 186.3 R .655(ying an)-.09 F .656 (ything that is already there.)-.135 F(This)5.156 E(is done by the)72 197.3 Q F1 -.333(re)2.25 G(ad).333 E F0(command `)2.25 E(`r')-.666 E 2.25('. The)-.666 F(command)2.25 E 2.25(rj)93.6 212.3 S(unk)-2.25 E .197 (will read the \214le `)72 227.3 R(`junk')-.666 E 2.447('i)-.666 G .197 (nto the b)-2.447 F(uf)-.18 E .196(fer; it adds it to the)-.225 F .576 (end of whate)72 238.3 R -.135(ve)-.225 G 2.826(ri).135 G 2.826(sa) -2.826 G .576(lready in the b)-2.826 F(uf)-.18 E(fer)-.225 E 5.076(.S) -.495 G 2.826(oi)-5.076 G 2.826(fw)-2.826 G 2.826(ed)-2.826 G 2.826(oa) -2.826 G(read after an edit:)72 249.3 Q 2.25(ej)93.6 264.3 S(unk)-2.25 E 2.25(rj)93.6 275.3 S(unk)-2.25 E .242(the b)72 290.3 R(uf)-.18 E .242 (fer will contain)-.225 F F1(two)2.491 E F0 .241(copies of the te)2.491 F .241(xt \(six lines\).)-.135 F(No)93.6 305.3 Q 2.25(wi)-.225 G 2.25 (st)-2.25 G(he time)-2.25 E(for all good men)93.6 316.3 Q (to come to the aid of their party)93.6 327.3 Q(.)-.585 E(No)93.6 338.3 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time)-2.25 E(for all good men)93.6 349.3 Q(to come to the aid of their party)93.6 360.3 Q(.)-.585 E(Lik)72 375.3 Q 2.666(et)-.09 G .416(he `)-2.666 F(`w')-.666 E 2.666('a)-.666 G .416(nd `)-2.666 F(`e')-.666 E 2.666('c)-.666 G .416(ommands, `)-2.666 F (`r')-.666 E 2.666('p)-.666 G .416(rints the num-)-2.666 F .741 (ber of characters read in, after the reading operation is)72 386.3 R (complete.)72 397.3 Q 1.209(Generally speaking, `)94.5 411.6 R(`r')-.666 E 3.46('i)-.666 G 3.46(sm)-3.46 G 1.21(uch less used than)-3.46 F -.666 (``)72 422.6 S(e').666 E('.)-.666 E F2(Exer)72 444.6 Q(cise 2:)-.162 E F0 .326(Experiment with the `)94.5 458.9 R(`e')-.666 E 2.575('c)-.666 G (ommand)-2.575 E F3(-)2.575 E F0 .325(try reading)2.575 F 1.132 (and printing v)72 469.9 R 1.132(arious \214les.)-.225 F -.99(Yo)5.632 G 3.382(um).99 G 1.132(ay get an error `)-3.382 F(`?')-.666 E(',)-.666 E .306(typically because you spelled the \214le name wrong.)72 480.9 R -.315(Tr)4.806 G(y).315 E .296 (alternately reading and appending to see that the)72 491.9 R 2.546(yw) -.135 G(ork)-2.636 E(similarly)72 502.9 Q 4.5(.V)-.585 G(erify that) -5.499 E(ed \214lename)93.6 517.9 Q(is e)72 532.9 Q(xactly equi)-.135 E -.225(va)-.225 G(lent to).225 E(ed)93.6 547.9 Q 2.25<658c>93.6 558.9 S (lename)-2.25 E(What does)72 573.9 Q 2.25<668c>93.6 588.9 S(lename)-2.25 E(do?)72 603.9 Q F2 .68(Printing the contents of the b)72 625.9 R(uffer) -.18 E F3(-)2.93 E F2 .68(the Print com-)2.93 F(mand `)72 636.9 Q(`p') -.567 E(')-.567 E F0 -.72(To)94.5 651.2 S F1(print)3.195 E F0 .225 (or list the contents of the b)2.475 F(uf)-.18 E .225(fer \(or parts) -.225 F(of it\) on the terminal, we use the print command)72 662.2 Q(p) 93.6 677.2 Q .083(The w)72 692.2 R .083(ay this is done is as follo)-.09 F 2.332(ws. W)-.225 F 2.332(es)-.72 G .082(pecify the lines)-2.332 F .595(where we w)72 703.2 R .596(ant printing to be)-.09 F .596 (gin and where we w)-.135 F .596(ant it)-.09 F .437 (to end, separated by a comma, and follo)72 714.2 R .436 (wed by the let-)-.225 F .756(ter `)72 725.2 R(`p')-.666 E 3.006 ('. Thus)-.666 F .756(to print the \214rst tw)3.006 F 3.006(ol)-.09 G .756(ines of the b)-3.006 F(uf)-.18 E(fer)-.225 E(,)-.36 E(for e)302.4 105 Q(xample, \(that is, lines 1 through 2\) we say)-.135 E 4.5 (1,2p \(starting)324 120 R(line=1, ending line=2 p\))2.25 E F1(Ed)302.4 135 Q F0(will respond with)2.25 E(No)324 150 Q 2.25(wi)-.225 G 2.25(st) -2.25 G(he time)-2.25 E(for all good men)324 161 Q 2.327(Suppose we w) 324.9 179.3 R 2.327(ant to print)-.09 F F1(all)4.577 E F0 2.327 (the lines in the)4.577 F -.18(bu)302.4 190.3 S -.225(ff).18 G(er).225 E 4.636(.W)-.495 G 2.386(ec)-5.356 G .137(ould use `)-2.386 F(`1,3p')-.666 E 2.387('a)-.666 G 2.387(sa)-2.387 G(bo)-2.387 E .407 -.135(ve i)-.135 H 2.387(fw).135 G 2.387(ek)-2.387 G(ne)-2.387 E 2.387(wt)-.225 G(here) -2.387 E 1.143(were e)302.4 201.3 R 1.143(xactly 3 lines in the b)-.135 F(uf)-.18 E(fer)-.225 E 5.643(.B)-.495 G 1.143(ut in general, we)-5.643 F(don')302.4 212.3 Q 2.649(tk)-.162 G(no)-2.649 E 2.649(wh)-.225 G .849 -.225(ow m)-2.649 H(an).225 E 2.649(yt)-.135 G .399 (here are, so what do we use for)-2.649 F .314(the ending line number?) 302.4 223.3 R F1(Ed)4.814 E F0(pro)2.564 E .314(vides a shorthand sym-) -.135 F .38(bol for `)302.4 234.3 R .38(`line number of last line in b) -.666 F(uf)-.18 E(fer')-.225 E(')-.666 E F3(-)2.631 E F0 .381 (the dollar)2.631 F(sign `)302.4 245.3 Q(`$')-.666 E 2.25('. Use)-.666 F (it this w)2.25 E(ay:)-.09 E(1,$p)324 260.3 Q .834(This will print)302.4 275.3 R F1(all)3.084 E F0 .834(the lines in the b)3.084 F(uf)-.18 E .834 (fer \(line 1 to last)-.225 F 3.245(line.\) If)302.4 286.3 R .995(you w) 3.245 F .996(ant to stop the printing before it is \214n-)-.09 F (ished, push the DEL or Delete k)302.4 297.3 Q -.135(ey)-.09 G(;).135 E F1(ed)2.25 E F0(will type)2.25 E(?)324 312.3 Q(and w)302.4 327.3 Q (ait for the ne)-.09 E(xt command.)-.135 E 1.44 -.72(To p)324.9 341.6 T (rint the).72 E F1(last)2.25 E F0(line of the b)2.25 E(uf)-.18 E(fer) -.225 E 2.25(,w)-.36 G 2.25(ec)-2.25 G(ould use)-2.25 E($,$p)324 356.6 Q -.18(bu)302.4 371.6 S(t).18 E F1(ed)2.25 E F0(lets us abbre)2.25 E (viate this to)-.225 E($p)324 386.6 Q 2.038 -.72(We c)302.4 401.6 T .598 (an print an).72 F 2.848(ys)-.135 G .597 (ingle line by typing the line number)-2.848 F(follo)302.4 412.6 Q (wed by a `)-.225 E(`p')-.666 E 2.25('. Thus)-.666 F(1p)324 427.6 Q (produces the response)302.4 442.6 Q(No)324 457.6 Q 2.25(wi)-.225 G 2.25 (st)-2.25 G(he time)-2.25 E(which is the \214rst line of the b)302.4 472.6 Q(uf)-.18 E(fer)-.225 E(.)-.495 E .315(In f)324.9 486.9 R(act,) -.09 E F1(ed)2.565 E F0 .315(lets us abbre)2.565 F .315(viate e)-.225 F -.135(ve)-.225 G 2.565(nf).135 G .315(urther: we can)-2.565 F .095 (print an)302.4 497.9 R 2.345(ys)-.135 G .095(ingle line by typing) -2.345 F F1(just)2.345 E F0 .095(the line number)2.345 F F3(-)2.345 E F0 (no)2.344 E(need to type the letter `)302.4 508.9 Q(`p')-.666 E 2.25 ('. So)-.666 F(if we say)2.25 E($)324 523.9 Q F1(ed)302.4 538.9 Q F0 (will print the last line of the b)2.25 E(uf)-.18 E(fer for us.)-.225 E 1.44 -.72(We c)324.9 553.2 T(an also use `).72 E(`$')-.666 E 2.25('i) -.666 G 2.25(nc)-2.25 G(ombinations lik)-2.25 E(e)-.09 E($)324 568.2 Q F3(-)A F0(1,$p)A .361(which prints the last tw)302.4 583.2 R 2.611(ol) -.09 G .361(ines of the b)-2.611 F(uf)-.18 E(fer)-.225 E 4.861(.T)-.495 G .361(his helps)-4.861 F(when we w)302.4 594.2 Q(ant to see ho)-.09 E 2.25(wf)-.225 G(ar we got in typing.)-2.34 E F2(Exer)302.4 616.2 Q (cise 3:)-.162 E F0 2.54(As before, create some te)324.9 630.5 R 2.539 (xt using the append)-.135 F .048(command and e)302.4 641.5 R .049 (xperiment with the `)-.135 F(`p')-.666 E 2.299('c)-.666 G 2.299 (ommand. Y)-2.299 F(ou)-.99 E 1.107(will \214nd, for e)302.4 652.5 R 1.106(xample, that you can')-.135 F 3.356(tp)-.162 G 1.106 (rint line 0 or a)-3.356 F .927(line be)302.4 663.5 R .928 (yond the end of the b)-.135 F(uf)-.18 E(fer)-.225 E 3.178(,a)-.36 G .928(nd that attempts to)-3.178 F(print a b)302.4 674.5 Q(uf)-.18 E (fer in re)-.225 E -.135(ve)-.225 G(rse order by saying).135 E(3,1p)324 689.5 Q(don')302.4 704.5 Q 2.25(tw)-.162 G(ork.)-2.34 E EP %%Page: 4 4 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893489>279 58 S/F1 9/Times-Bold@0 SF(The curr)72 105 Q(ent line)-.162 E/F2 9/Symbol SF(-)2.25 E F1 -.567 (``)2.25 G(Dot').567 E 2.25('o)-.567 G 2.25(r`)-2.25 G(`.)-2.817 E -.567 ('')-.495 G F0 .94(Suppose our b)94.5 119.3 R(uf)-.18 E .939 (fer still contains the six lines as)-.225 F(abo)72 130.3 Q -.135(ve) -.135 G 2.25(,t).135 G(hat we ha)-2.25 E .27 -.135(ve j)-.18 H (ust typed).135 E(1,3p)93.6 145.3 Q(and)72 160.3 Q/F3 9/Times-Italic@0 SF(ed)2.267 E F0 .017(has printed the three lines for us.)2.267 F -.315 (Tr)4.517 G 2.268(yt).315 G .018(yping just)-2.268 F 18(p\()93.6 175.3 S (no line numbers\).)-18 E(This will print)72 190.3 Q (to come to the aid of their party)93.6 205.3 Q(.)-.585 E .259 (which is the third line of the b)72 220.3 R(uf)-.18 E(fer)-.225 E 4.759 (.I)-.495 G 2.509(nf)-4.759 G .259(act it is the last)-2.599 F 2.104 (\(most recent\) line that we ha)72 231.3 R 2.374 -.135(ve d)-.18 H 2.104(one an).135 F 2.104(ything with.)-.135 F(\(W)72 242.3 Q 2.797(ej) -.72 G .547(ust printed it!\))-2.797 F 1.987 -.72(We c)5.047 H .547 (an repeat this `).72 F(`p')-.666 E 2.797('c)-.666 G(ommand)-2.797 E .733(without line numbers, and it will continue to print line)72 253.3 R (3.)72 264.3 Q 1.432(The reason is that)94.5 278.6 R F3(ed)3.682 E F0 1.432(maintains a record of the)3.682 F 1.454(last line that we did an) 72 289.6 R 1.454(ything to \(in this case, line 3,)-.135 F .534 (which we just printed\) so that it can be used instead of)72 300.6 R 1.778(an e)72 311.6 R 1.778(xplicit line number)-.135 F 6.278(.T)-.495 G 1.778(his most recent line is re-)-6.278 F (ferred to by the shorthand symbol)72 322.6 Q F1(.)93.6 337.6 Q F0 (\(pronounced `)20.25 E(`dot')-.666 E('\).)-.666 E 1.379 (Dot is a line number in the same w)72 352.6 R 1.378(ay that `)-.09 F (`$')-.666 E 3.628('i)-.666 G 1.378(s; it)-3.628 F .858(means e)72 363.6 R .858(xactly `)-.135 F .858(`the current line')-.666 F .858 (', or loosely)-.666 F 3.109(,`)-.585 G .859(`the line)-3.775 F .864 (we most recently did something to.)72 374.6 R 4.446 -.666('' W)-.63 H 3.114(ec)-.054 G .864(an use it in)-3.114 F(se)72 385.6 Q -.135(ve)-.225 G(ral w).135 E(ays)-.09 E F2(-)2.25 E F0(one possibility is to say)2.25 E F1(.)93.6 400.6 Q F0(,$p)A .374 (This will print all the lines from \(including\) the current)72 415.6 R .38(line to the end of the b)72 426.6 R(uf)-.18 E(fer)-.225 E 4.879(.I) -.495 G 2.629(no)-4.879 G .379(ur case these are lines)-2.629 F 2.25(3t) 72 437.6 S(hrough 6.)-2.25 E .978(Some commands change the v)94.5 451.9 R .979(alue of dot, while)-.225 F .361(others do not.)72 462.9 R .361 (The print command sets dot to the num-)4.861 F 1.337 (ber of the last line printed; by our last command, we)72 473.9 R -.09 (wo)72 484.9 S(uld ha).09 E .27 -.135(ve `)-.18 H(`)-.531 E F1(.)A F0 1.332 -.666('' = ``)D($').666 E 2.25('=6)-.666 G(.)-2.25 E 1.836 (Dot is most useful when used in combinations)94.5 499.2 R(lik)72 510.2 Q 2.25(et)-.09 G(his one:)-2.25 E F1(.)93.6 525.2 Q F0 8.424(+1 \(or)B (equi)2.25 E -.225(va)-.225 G(lently).225 E(,)-.585 E F1(.)2.25 E F0 (+1p\))A .695(This means `)72 540.2 R .695(`print the ne)-.666 F .696 (xt line')-.135 F 2.946('a)-.666 G .696(nd gi)-2.946 F -.135(ve)-.225 G 2.946(su).135 G 2.946(sah)-2.946 G(andy)-2.946 E -.09(wa)72 551.2 S 2.25 (yt).09 G 2.25(os)-2.25 G(tep slo)-2.25 E(wly through a b)-.225 E(uf) -.18 E(fer)-.225 E 4.5(.W)-.495 G 2.25(ec)-5.22 G(an also say)-2.25 E F1 (.)93.6 566.2 Q F2(-)A F0 10.809(1\()C(or)-10.809 E F1(.)2.25 E F2(-)A F0(1p \))A 1.524(which means `)72 581.2 R 1.523(`print the line)-.666 F F3(befor)3.773 E(e)-.333 E F0 1.523(the current line.)3.773 F -.666('') -.63 G .997(This enables us to go backw)72 592.2 R .997 (ards if we wish.)-.09 F(Another)5.497 E(useful one is something lik)72 603.2 Q(e)-.09 E F1(.)93.6 618.2 Q F2(-)A F0(3,)A F1(.)A F2(-)A F0(1p)A (which prints the pre)72 633.2 Q(vious three lines.)-.225 E(Don')94.5 647.5 Q 2.799(tf)-.162 G(or)-2.799 E .549 (get that all of these change the v)-.162 F .549(alue of)-.225 F 2.25 (dot. Y)72 658.5 R(ou can \214nd out what dot is at an)-.99 E 2.25(yt) -.135 G(ime by typing)-2.25 E F1(.)93.6 673.5 Q F0(=)A F3(Ed)72 688.5 Q F0(will respond by printing the v)2.25 E(alue of dot.)-.225 E(Let')94.5 702.8 Q 2.279(ss)-.495 G .03(ummarize some things about the `)-2.279 F (`p')-.666 E 2.28('c)-.666 G(om-)-2.28 E .942(mand and dot.)72 713.8 R .942(Essentially `)5.442 F(`p')-.666 E 3.192('c)-.666 G .942 (an be preceded by 0,)-3.192 F .657(1, or 2 line numbers.)72 724.8 R .658(If there is no line number gi)5.158 F -.135(ve)-.225 G(n,).135 E .089(it prints the `)302.4 105 R .089(`current line')-.666 F .088 (', the line that dot refers to.)-.666 F(If)4.588 E .448 (there is one line number gi)302.4 116 R -.135(ve)-.225 G 2.698(n\().135 G .448(with or without the let-)-2.698 F .56(ter `)302.4 127 R(`p')-.666 E .559('\), it prints that line \(and dot is set there\); and if)-.666 F .427(there are tw)302.4 138 R 2.678(ol)-.09 G .428 (ine numbers, it prints all the lines in that)-2.678 F .543 (range \(and sets dot to the last line printed.\))302.4 149 R .542 (If tw)5.042 F 2.792(ol)-.09 G(ine)-2.792 E .728 (numbers are speci\214ed the \214rst can')302.4 160 R 2.978(tb)-.162 G 2.978(eb)-2.978 G .728(igger than the)-2.978 F(second \(see Ex)302.4 171 Q(ercise 2.\))-.135 E -.72(Ty)324.9 185.3 S .133(ping a single ne).72 F .133(wline will cause printing of the)-.225 F(ne)302.4 196.3 Q .089 (xt line)-.135 F F2(-)2.339 E F0(it')2.339 E 2.339(se)-.495 G(qui)-2.339 E -.225(va)-.225 G .089(lent to `).225 F(`)-.666 E F1(.)A F0(+1p')A 2.339('. T)-.666 F .089(ry it.)-.315 F -.315(Tr)4.589 G 2.34(yt).315 G (yping)-2.34 E -.666(``)302.4 207.3 S(^').666 E(')-.666 E F2(-)2.25 E F0 (it')2.25 E 2.25(se)-.495 G(qui)-2.25 E -.225(va)-.225 G(lent to `).225 E(`)-.666 E F1(.)A F2(-)A F0(1p')A('.)-.666 E F1(Deleting lines: the `) 302.4 229.3 Q(`d')-.567 E 2.25('c)-.567 G(ommand)-2.25 E F0 2.012 (Suppose we w)324.9 243.6 R 2.012(ant to get rid of the three e)-.09 F (xtra)-.135 E .202(lines in the b)302.4 254.6 R(uf)-.18 E(fer)-.225 E 4.702(.T)-.495 G .203(his is done by the)-4.702 F F3(delete)2.453 E F0 (command)2.453 E(d)324 269.6 Q .777(Except that `)302.4 284.6 R(`d') -.666 E 3.026('d)-.666 G .776(eletes lines instead of printing them,) -3.026 F 1.927(its action is similar to that of `)302.4 295.6 R(`p') -.666 E 4.177('. The)-.666 F 1.927(lines to be)4.177 F 1.836 (deleted are speci\214ed for `)302.4 306.6 R(`d')-.666 E 4.086('e)-.666 G 1.836(xactly as the)-4.221 F 4.086(ya)-.135 G 1.836(re for)-4.086 F -.666(``)302.4 317.6 S(p').666 E(':)-.666 E F3(starting line)324 332.6 Q 2.25(,e)-.09 G(nding line)-2.25 E F0(d)2.25 E(Thus the command)302.4 347.6 Q(4,$d)324 362.6 Q 1.458(deletes lines 4 through the end.)302.4 377.6 R 1.458(There are no)5.958 F 3.708(wt)-.225 G(hree)-3.708 E (lines left, as we can check by using)302.4 388.6 Q(1,$p)324 403.6 Q 1.369(And notice that `)302.4 418.6 R(`$')-.666 E 3.619('n)-.666 G 1.819 -.225(ow i)-3.619 H 3.619(sl).225 G 1.369(ine 3!)-3.619 F 1.368 (Dot is set to the)5.869 F(ne)302.4 429.6 Q .901 (xt line after the last line deleted, unless the last line)-.135 F .482 (deleted is the last line in the b)302.4 440.6 R(uf)-.18 E(fer)-.225 E 4.981(.I)-.495 G 2.731(nt)-4.981 G .481(hat case, dot is)-2.731 F (set to `)302.4 451.6 Q(`$')-.666 E('.)-.666 E F1(Exer)302.4 473.6 Q (cise 4:)-.162 E F0 .834(Experiment with `)324.9 487.9 R(`a')-.666 E .834(', `)-.666 F(`e')-.666 E .834(', `)-.666 F(`r')-.666 E .835(', `) -.666 F(`w')-.666 E .835(', `)-.666 F(`p')-.666 E .835(', and)-.666 F -.666(``)302.4 498.9 S(d').666 E 2.417('u)-.666 G .166 (ntil you are sure that you kno)-2.417 F 2.416(ww)-.225 G .166(hat the) -2.416 F 2.416(yd)-.135 G .166(o, and)-2.416 F 1.272 (until you understand ho)302.4 509.9 R 3.522(wd)-.225 G 1.272(ot, `) -3.522 F(`$')-.666 E 1.273(', and line numbers)-.666 F(are used.)302.4 520.9 Q 1.823(If you are adv)324.9 535.2 R 1.823 (enturous, try using line numbers)-.135 F 1.663(with `)302.4 546.2 R (`a')-.666 E 1.663(', `)-.666 F(`r')-.666 E 1.663(', and `)-.666 F(`w') -.666 E 3.913('a)-.666 G 3.913(sw)-3.913 G 3.913(ell. Y)-3.913 F 1.664 (ou will \214nd that)-.99 F -.666(``)302.4 557.2 S(a').666 E 3.773('w) -.666 G 1.523(ill append lines)-3.773 F F3(after)3.773 E F0 1.523 (the line number that you)3.773 F 1.149 (specify \(rather than after dot\); that `)302.4 568.2 R(`r')-.666 E 3.399('r)-.666 G 1.15(eads a \214le in)-3.399 F F3(after)302.4 579.2 Q F0 .098(the line number you specify \(not necessarily at the)2.348 F .702(end of the b)302.4 590.2 R(uf)-.18 E .702(fer\); and that `)-.225 F (`w')-.666 E 2.952('w)-.666 G .702(ill write out e)-2.952 F(xactly)-.135 E .828(the lines you specify)302.4 601.2 R 3.078(,n)-.585 G .828 (ot necessarily the whole b)-3.078 F(uf)-.18 E(fer)-.225 E(.)-.495 E 2.346(These v)302.4 612.2 R 2.346(ariations are sometimes handy)-.225 F 6.846(.F)-.585 G 2.346(or instance)-6.981 F .224 (you can insert a \214le at the be)302.4 623.2 R .223(ginning of a b) -.135 F(uf)-.18 E .223(fer by say-)-.225 F(ing)302.4 634.2 Q (0r \214lename)324 649.2 Q .039(and you can enter lines at the be)302.4 664.2 R .04(ginning of the b)-.135 F(uf)-.18 E .04(fer by)-.225 F (saying)302.4 675.2 Q(0a)324 690.2 Q 2.25(...)324 701.2 S F3(te)A(xt) -.18 E F0 2.25(...)2.25 G F1(.)324 712.2 Q F0(Notice that `)302.4 727.2 Q(`)-.666 E F1(.)A F0(w')A 2.25('i)-.666 G(s)-2.25 E F3(very)2.25 E F0 (dif)2.25 E(ferent from)-.225 E EP %%Page: 5 5 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893589>279 58 S/F1 9/Times-Bold@0 SF(.)93.6 105 Q F0(w)93.6 116 Q F1 (Modifying text: the Substitute command `)72 142 Q(`s')-.567 E(')-.567 E F0 2.267 -.72(We a)94.5 156.3 T .827(re no).72 F 3.076(wr)-.225 G .826 (eady to try one of the most impor)-3.076 F(-)-.18 E (tant of all commands)72 167.3 Q/F2 9/Symbol SF(-)2.25 E F0 (the substitute command)2.25 E(s)93.6 182.3 Q .898 (This is the command that is used to change indi)72 197.3 R(vidual)-.225 E -.09(wo)72 208.3 S 1.451 (rds or letters within a line or group of lines.).09 F 1.45(It is)5.95 F .847(what we use, for e)72 219.3 R .847 (xample, for correcting spelling mis-)-.135 F(tak)72 230.3 Q (es and typing errors.)-.09 E(Suppose that by a typing error)94.5 244.6 Q 2.25(,l)-.36 G(ine 1 says)-2.25 E(No)93.6 259.6 Q 2.25(wi)-.225 G 2.25 (st)-2.25 G 2.25(ht)-2.25 G(ime)-2.25 E F2(-)72 274.6 Q F0 .765(the `) 3.015 F(`e')-.666 E 3.015('h)-.666 G .765(as been left of)-3.015 F 3.015 (f`)-.225 G(`the')-3.681 E 3.015('. W)-.666 F 3.015(ec)-.72 G .765 (an use `)-3.015 F(`s')-.666 E 3.015('t)-.666 G(o)-3.015 E (\214x this up as follo)72 285.6 Q(ws:)-.225 E(1s/th/the/)93.6 300.6 Q 1.033(This says: `)72 315.6 R 1.033 (`in line 1, substitute for the characters `th')-.666 F 1.238 (the characters `the'.)72 326.6 R 4.82 -.666('' T)-.63 H 3.488(ov)-.054 G 1.238(erify that it w)-3.623 F 1.238(orks \()-.09 F/F3 9 /Times-Italic@0 SF(ed)A F0(will)3.488 E (not print the result automatically\) we say)72 337.6 Q(p)93.6 352.6 Q (and get)72 367.6 Q(No)93.6 382.6 Q 2.25(wi)-.225 G 2.25(st)-2.25 G (he time)-2.25 E 1.309(which is what we w)72 397.6 R 3.559 (anted. Notice)-.09 F 1.309(that dot must ha)3.559 F -.135(ve)-.18 G 1.18(been set to the line where the substitution took place,)72 408.6 R 1.69(since the `)72 419.6 R(`p')-.666 E 3.94('c)-.666 G 1.69 (ommand printed that line.)-3.94 F 1.69(Dot is al-)6.19 F -.09(wa)72 430.6 S(ys set this w).09 E(ay with the `)-.09 E(`s')-.666 E 2.25('c) -.666 G(ommand.)-2.25 E 1.138(The general w)94.5 444.9 R 1.138 (ay to use the substitute command)-.09 F(is)72 455.9 Q F3 (starting\211line)93.6 470.9 Q 2.25(,e)-.09 G(nding\211line)-2.25 E F0 (s/)2.25 E F3 -.135(ch)C(ang).135 E 2.25(et)-.09 G(his)-2.25 E F0(/)A F3 (to this)A F0(/)A(Whate)72 485.9 Q -.135(ve)-.225 G 3.439(rs).135 G 1.189(tring of characters is between the \214rst pair)-3.439 F .974 (of slashes is replaced by whate)72 496.9 R -.135(ve)-.225 G 3.224(ri) .135 G 3.224(sb)-3.224 G .974(etween the sec-)-3.224 F .573(ond pair)72 507.9 R 2.823(,i)-.36 G(n)-2.823 E F3(all)2.823 E F0 .573 (the lines between starting line and end-)2.823 F 2.709(ing line.)72 518.9 R 2.709(Only the \214rst occurrence on each line is)7.209 F .676 (changed, ho)72 529.9 R(we)-.225 E -.135(ve)-.225 G 3.916 -.495(r. I) .135 H 2.926(fy).495 G .676(ou w)-2.926 F .676(ant to change)-.09 F F3 -.135(ev)2.926 G(ery).135 E F0(occur)2.927 E(-)-.18 E 1.2(rence, see Ex) 72 540.9 R 1.2(ercise 5.)-.135 F 1.2(The rules for line numbers are)5.7 F .696(the same as those for `)72 551.9 R(`p')-.666 E .696(', e)-.666 F .696(xcept that dot is set to the)-.135 F .18(last line changed.)72 562.9 R .18(\(But there is a trap for the unw)4.68 F .18(ary: if)-.09 F 1.981(no substitution took place, dot is)72 573.9 R F3(not)4.231 E F0 4.232(changed. This)4.231 F(causes an error `)72 584.9 Q(`?')-.666 E 2.25('a)-.666 G 2.25(saw)-2.25 G(arning.\))-2.34 E(Thus we can say)94.5 599.2 Q(1,$s/speling/spelling/)93.6 614.2 Q .272 (and correct the \214rst spelling mistak)72 629.2 R 2.522(eo)-.09 G 2.522(ne)-2.522 G .271(ach line in the)-2.522 F(te)72 640.2 Q 2.64 (xt. \(This)-.135 F .39(is useful for people who are consistent mis-) 2.64 F(spellers!\))72 651.2 Q 1.01(If no line numbers are gi)94.5 665.5 R -.135(ve)-.225 G 1.01(n, the `).135 F(`s')-.666 E 3.26('c)-.666 G (ommand)-3.26 E .536(assumes we mean `)72 676.5 R(`mak)-.666 E 2.787(et) -.09 G .537(he substitution on line dot')-2.787 F(',)-.666 E .112 (so it changes things only on the current line.)72 687.5 R .111 (This leads)4.611 F(to the v)72 698.5 Q(ery common sequence)-.135 E (s/something/something else/p)93.6 713.5 Q 1.122(which mak)72 728.5 R 1.123(es some correction on the current line, and)-.09 F 1.489 (then prints it, to mak)302.4 105 R 3.739(es)-.09 G 1.489(ure it w) -3.739 F(ork)-.09 E 1.489(ed out right.)-.09 F 1.489(If it)5.989 F (didn')302.4 116 Q 1.509(t, we can try ag)-.162 F 3.759(ain. \(Notice) -.045 F 1.51(that we put a print)3.759 F .606 (command on the same line as the substitute.)302.4 127 R -.36(Wi)5.106 G .606(th fe).36 F(w)-.225 E -.135(ex)302.4 138 S 2.28(ceptions, `).135 F (`p')-.666 E 4.531('c)-.666 G 2.281(an follo)-4.531 F 4.531(wa)-.225 G 2.551 -.135(ny c)-4.531 H 2.281(ommand; no other).135 F (multi-command lines are le)302.4 149 Q -.045(ga)-.135 G(l.\)).045 E (It')324.9 163.3 Q 2.25(sa)-.495 G(lso le)-2.25 E -.045(ga)-.135 G 2.25 (lt).045 G 2.25(os)-2.25 G(ay)-2.25 E(s/ . . . //)324 178.3 Q 1.415 (which means `)302.4 193.3 R 1.414 (`change the \214rst string of characters to)-.666 F F3(nothing)302.4 204.3 Q F0 -.666('')C 2.569(,i).666 G .319(.e., remo)-2.569 F .589 -.135 (ve t)-.135 H 2.569(hem. This).135 F .32(is useful for deleting)2.57 F -.135(ex)302.4 215.3 S 1.987(tra w).135 F 1.987(ords in a line or remo) -.09 F 1.987(ving e)-.135 F 1.987(xtra letters from)-.135 F -.09(wo) 302.4 226.3 S 2.25(rds. F).09 F(or instance, if we had)-.135 E(No)324 241.3 Q(wxx is the time)-.225 E(we can say)302.4 256.3 Q(s/xx//p)324 271.3 Q(to get)302.4 286.3 Q(No)324 301.3 Q 2.25(wi)-.225 G 2.25(st) -2.25 G(he time)-2.25 E 2.26(Notice that `)302.4 316.3 R(`//')-.666 E 4.51('h)-.666 G 2.26(ere means `)-4.51 F 2.26(`no characters')-.666 F 2.26(', not a)-.666 F 3.671(blank. There)302.4 327.3 R F3(is)3.671 E F0 3.671(ad)3.671 G(if)-3.671 E 3.671(ference! \(See)-.225 F(belo)3.671 E 3.671(wf)-.225 G 1.42(or another)-3.671 F(meaning of `)302.4 338.3 Q (`//')-.666 E('.\))-.666 E F1(Exer)302.4 360.3 Q(cise 5:)-.162 E F0 2.271(Experiment with the substitute command.)324.9 374.6 R(See)6.772 E .421(what happens if you substitute for some w)302.4 385.6 R .421 (ord on a line)-.09 F .202(with se)302.4 396.6 R -.135(ve)-.225 G .202 (ral occurrences of that w).135 F 2.453(ord. F)-.09 F .203(or e)-.135 F .203(xample, do)-.135 F(this:)302.4 407.6 Q(a)324 422.6 Q (the other side of the coin)324 433.6 Q F1(.)324 444.6 Q F0 (s/the/on the/p)324 455.6 Q -.99(Yo)302.4 470.6 S 2.25(uw).99 G(ill get) -2.25 E(on the other side of the coin)324 485.6 Q 4.615(As)302.4 500.6 S 2.364(ubstitute command changes only the \214rst occur)-4.615 F(-)-.18 E 2.23(rence of the \214rst string.)302.4 511.6 R -.99(Yo)6.73 G 4.48(uc) .99 G 2.23(an change all occur)-4.48 F(-)-.18 E .317 (rences by adding a `)302.4 522.6 R(`g')-.666 E 2.567('\()-.666 G .317 (for `)-2.567 F(`global')-.666 E .317('\) to the `)-.666 F(`s')-.666 E 2.566('c)-.666 G(om-)-2.566 E(mand, lik)302.4 533.6 Q 2.25(et)-.09 G (his:)-2.25 E(s/ . . . / . . . /gp)324 548.6 Q -.315(Tr)302.4 563.6 S 3.993(yo).315 G 1.744(ther characters instead of slashes to delimit the) -3.993 F(tw)302.4 574.6 Q 2.973(os)-.09 G .723 (ets of characters in the `)-2.973 F(`s')-.666 E 2.973('c)-.666 G (ommand)-2.973 E F2(-)2.973 E F0(an)2.973 E(ything)-.135 E(should w) 302.4 585.6 Q(ork e)-.09 E(xcept blanks or tabs.)-.135 E .407 (\(If you get funn)324.9 599.9 R 2.657(yr)-.135 G .407(esults using an) -2.657 F 2.657(yo)-.135 G 2.657(ft)-2.657 G .407(he charac-)-2.657 F (ters)302.4 610.9 Q(^)324 625.9 Q F1(.)9 E F0 9($[*\\)9 G (read the section on `)302.4 640.9 Q(`Special Characters')-.666 E('.\)) -.666 E EP %%Page: 6 6 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893689>279 58 S/F1 9/Times-Bold@0 SF(Context sear)72 105 Q(ching)-.162 E/F2 9/Symbol SF(-)2.25 E F1 -.567 (``)2.25 G 2.25(/.../).567 G -.567('')-2.25 G F0 -.36(Wi)94.5 119.3 S 1.539(th the substitute command mastered, we can).36 F(mo)72 130.3 Q .915 -.135(ve o)-.135 H 2.895(nt).135 G 2.895(oa)-2.895 G .645 (nother highly important idea of)-2.895 F/F3 9/Times-Italic@0 SF(ed) 2.896 E F2(-)2.896 E F0(con-)2.896 E(te)72 141.3 Q(xt searching.)-.135 E 1.447(Suppose we ha)94.5 155.6 R 1.717 -.135(ve o)-.18 H 1.447 (ur original three line te).135 F 1.446(xt in)-.135 F(the b)72 166.6 Q (uf)-.18 E(fer:)-.225 E(No)93.6 181.6 Q 2.25(wi)-.225 G 2.25(st)-2.25 G (he time)-2.25 E(for all good men)93.6 192.6 Q (to come to the aid of their party)93.6 203.6 Q(.)-.585 E .755 (Suppose we w)72 218.6 R .755(ant to \214nd the line that contains `) -.09 F(`their')-.666 E(')-.666 E 1.72(so we can change it to `)72 229.6 R(`the')-.666 E 3.97('. No)-.666 F 3.97(ww)-.225 G 1.72(ith only three) -3.97 F .317(lines in the b)72 240.6 R(uf)-.18 E(fer)-.225 E 2.567(,i) -.36 G(t')-2.567 E 2.567(sp)-.495 G .318(retty easy to k)-2.567 F .318 (eep track of what)-.09 F .347(line the w)72 251.6 R .347(ord `)-.09 F (`their')-.666 E 2.597('i)-.666 G 2.597(so)-2.597 G 2.596(n. But)-2.597 F .346(if the b)2.596 F(uf)-.18 E .346(fer contained)-.225 F(se)72 262.6 Q -.135(ve)-.225 G .887(ral hundred lines, and we').135 F 3.137(db)-.45 G .887(een making changes,)-3.137 F .497 (deleting and rearranging lines, and so on, we w)72 273.6 R .497 (ould no)-.09 F 1.96(longer really kno)72 284.6 R 4.211(ww)-.225 G 1.961 (hat this line number w)-4.211 F 1.961(ould be.)-.09 F(Conte)72 295.6 Q .406(xt searching is simply a method of specifying the)-.135 F .396 (desired line, re)72 306.6 R -.045(ga)-.135 G .396 (rdless of what its number is, by speci-).045 F(fying some conte)72 317.6 Q(xt on it.)-.135 E .851(The w)94.5 331.9 R .851(ay we say `)-.09 F .851(`search for a line that contains)-.666 F (this particular string of characters')72 342.9 Q 2.25('i)-.666 G 2.25 (st)-2.25 G 2.25(ot)-2.25 G(ype)-2.25 E(/)93.6 357.9 Q F3(string of c)A (har)-.135 E(acter)-.135 E 2.25(sw)-.09 G 2.25(ew)-2.25 G(ant to \214nd) -2.25 E F0(/)A -.135(Fo)72 372.9 S 2.25(re).135 G(xample, the)-2.385 E F3(ed)2.25 E F0(line)2.25 E(/their/)93.6 387.9 Q .048(is a conte)72 402.9 R .048(xt search which is suf)-.135 F .049 (\214cient to \214nd the desired)-.225 F(line)72 413.9 Q F2(-)3.186 E F0 .935(it will locate the ne)3.185 F .935(xt occurrence of the charac-) -.135 F 1.08(ters between slashes \(`)72 424.9 R(`their')-.666 E 3.33 ('\). It)-.666 F 1.08(also sets dot to that)3.33 F (line and prints the line for v)72 435.9 Q(eri\214cation:)-.135 E (to come to the aid of their party)93.6 450.9 Q(.)-.585 E -.666(``)72 465.9 S(Ne).666 E .391(xt occurrence')-.135 F 2.641('m)-.666 G .391 (eans that)-2.641 F F3(ed)2.64 E F0 .39(starts looking for the)2.64 F 1.042(string at line `)72 476.9 R(`)-.666 E F1(.)A F0(+1')A 1.042 (', searches to the end of the b)-.666 F(uf)-.18 E(fer)-.225 E(,)-.36 E .513(then continues at line 1 and searches to line dot.)72 487.9 R (\(That)5.013 E .307(is, the search `)72 498.9 R .308(`wraps around') -.666 F 2.558('f)-.666 G .308(rom `)-2.558 F(`$')-.666 E 2.558('t)-.666 G 2.558(o1)-2.558 G 2.558(.\) It)-2.558 F(scans)2.558 E .343 (all the lines in the b)72 509.9 R(uf)-.18 E .343 (fer until it either \214nds the desired)-.225 F 1.571 (line or gets back to dot ag)72 520.9 R 3.821(ain. If)-.045 F 1.571 (the gi)3.821 F -.135(ve)-.225 G 3.821(ns).135 G 1.571(tring of)-3.821 F .371(characters can')72 531.9 R 2.621(tb)-.162 G 2.621(ef)-2.621 G .371 (ound in an)-2.621 F 2.621(yl)-.135 G(ine,)-2.621 E F3(ed)2.621 E F0 .37 (types the error)2.621 F(message)72 542.9 Q(?)93.6 557.9 Q (Otherwise it prints the line it found.)72 572.9 Q 3.064 -.72(We c)94.5 587.2 T 1.624(an do both the search for the desired line).72 F F3(and)72 598.2 Q F0 2.25(as)2.25 G(ubstitution all at once, lik)-2.25 E 2.25(et) -.09 G(his:)-2.25 E(/their/s/their/the/p)93.6 613.2 Q(which will yield) 72 628.2 Q(to come to the aid of the party)93.6 643.2 Q(.)-.585 E 1.535 (There were three parts to that last command: conte)72 658.2 R(xt)-.135 E .714(search for the desired line, mak)72 669.2 R 2.965(et)-.09 G .715 (he substitution, print)-2.965 F(the line.)72 680.2 Q 1.163(The e)94.5 694.5 R 1.163(xpression `)-.135 F(`/their/')-.666 E 3.412('i)-.666 G 3.412(sac)-3.412 G(onte)-3.412 E 1.162(xt search e)-.135 F(x-)-.135 E 2.956(pression. In)72 705.5 R .706(their simplest form, all conte)2.956 F .707(xt search e)-.135 F(x-)-.135 E .227(pressions are lik)72 716.5 R 2.477(et)-.09 G(his)-2.477 E F2(-)2.477 E F0 2.477(as)2.477 G .227 (tring of characters surround-)-2.477 F 2.298(ed by slashes.)72 727.5 R (Conte)6.798 E 2.298(xt searches are interchangeable)-.135 F .988 (with line numbers, so the)302.4 105 R 3.238(yc)-.135 G .988 (an be used by themselv)-3.238 F(es)-.135 E .92 (to \214nd and print a desired line, or as line numbers for)302.4 116 R 1.753(some other command, lik)302.4 127 R 4.003(e`)-.09 G(`s')-4.669 E 4.003('. W)-.666 F 4.003(eu)-.72 G 1.752(sed them both)-4.003 F -.09(wa) 302.4 138 S(ys in the e).09 E(xamples abo)-.135 E -.135(ve)-.135 G(.) .135 E 2.521(Suppose the b)324.9 152.3 R(uf)-.18 E 2.522 (fer contains the three f)-.225 F(amiliar)-.09 E(lines)302.4 163.3 Q(No) 324 178.3 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time)-2.25 E (for all good men)324 189.3 Q(to come to the aid of their party)324 200.3 Q(.)-.585 E(Then the)302.4 215.3 Q F3(ed)2.25 E F0(line numbers) 2.25 E(/No)324 230.3 Q(w/+1)-.225 E(/good/)324 241.3 Q(/party/)324 252.3 Q F2(-)A F0(1)A .729(are all conte)302.4 267.3 R .729(xt search e)-.135 F .729(xpressions, and the)-.135 F 2.979(ya)-.135 G .729(ll refer to) -2.979 F .6(the same line \(line 2\).)302.4 278.3 R 2.04 -.72(To m)5.1 H (ak).72 E 2.85(eac)-.09 G .6(hange in line 2, we)-2.85 F(could say)302.4 289.3 Q(/No)324 304.3 Q(w/+1s/good/bad/)-.225 E(or)302.4 319.3 Q (/good/s/good/bad/)324 334.3 Q(or)302.4 349.3 Q(/party/)324 364.3 Q F2 (-)A F0(1s/good/bad/)A .733(The choice is dictated only by con)302.4 379.3 R -.135(ve)-.36 G 2.982(nience. W).135 F 2.982(ec)-.72 G(ould) -2.982 E(print all three lines by)302.4 390.3 Q 2.25(,f)-.585 G (or instance)-2.25 E(/No)324 405.3 Q(w/,/party/p)-.225 E(or)302.4 420.3 Q(/No)324 435.3 Q(w/,/No)-.225 E(w/+2p)-.225 E 1.656(or by an)302.4 450.3 R 3.906(yn)-.135 G 1.656(umber of similar combinations.)-3.906 F 1.656(The \214rst)6.156 F 2.024(one of these might be better if we don') 302.4 461.3 R 4.274(tk)-.162 G(no)-4.274 E 4.274(wh)-.225 G -.225(ow) -4.274 G(man)302.4 472.3 Q 2.579(yl)-.135 G .329(ines are in)-2.579 F -.18(vo)-.36 G(lv).18 E 2.579(ed. \(Of)-.135 F .329 (course, if there were only)2.579 F(three lines in the b)302.4 483.3 Q (uf)-.18 E(fer)-.225 E 2.25(,w)-.36 G(e')-2.25 E 2.25(du)-.45 G(se)-2.25 E(1,$p)324 498.3 Q -.18(bu)302.4 513.3 S 2.25(tn).18 G (ot if there were se)-2.25 E -.135(ve)-.225 G(ral hundred.\)).135 E 1.051(The basic rule is: a conte)324.9 527.6 R 1.051(xt search e)-.135 F 1.05(xpression is)-.135 F F3 .218(the same as)302.4 538.6 R F0 2.468(al) 2.468 G .218(ine number)-2.468 F 2.468(,s)-.36 G 2.468(oi)-2.468 G 2.468 (tc)-2.468 G .219(an be used where)-2.468 F -.135(ve)-.225 G 2.469(ra) .135 G(line number is needed.)302.4 549.6 Q F1(Exer)302.4 571.6 Q (cise 6:)-.162 E F0 1.263(Experiment with conte)324.9 585.9 R 1.263 (xt searching.)-.135 F -.315(Tr)5.763 G 3.513(yab).315 G(ody)-3.513 E 1.266(of te)302.4 596.9 R 1.266(xt with se)-.135 F -.135(ve)-.225 G 1.266(ral occurrences of the same string of).135 F .941 (characters, and scan through it using the same conte)302.4 607.9 R(xt) -.135 E(search.)302.4 618.9 Q -.315(Tr)324.9 633.2 S 3.94(yu).315 G 1.69 (sing conte)-3.94 F 1.691(xt searches as line numbers for)-.135 F 1.323 (the substitute, print and delete commands.)302.4 644.2 R(\(The)5.823 E 3.573(yc)-.135 G(an)-3.573 E(also be used with `)302.4 655.2 Q(`r')-.666 E(', `)-.666 E(`w')-.666 E(', and `)-.666 E(`a')-.666 E('.\))-.666 E -.315(Tr)324.9 669.5 S 3.51(yc).315 G(onte)-3.51 E 1.26 (xt searching using `)-.135 F(`?te)-.666 E(xt?')-.135 E 3.51('i)-.666 G 1.26(nstead of)-3.51 F -.666(``)302.4 680.5 S(/te).666 E(xt/')-.135 E 2.709('. This)-.666 F .459(scans lines in the b)2.709 F(uf)-.18 E .459 (fer in re)-.225 F -.135(ve)-.225 G .459(rse order).135 F .485 (rather than normal.)302.4 691.5 R .485 (This is sometimes useful if you go)4.985 F .028(too f)302.4 702.5 R .028(ar while looking for some string of characters)-.09 F F2(-)2.278 E F0(it')2.277 E(s)-.495 E(an easy w)302.4 713.5 Q(ay to back up.)-.09 E EP %%Page: 7 7 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893789>279 58 S .796 (\(If you get funn)94.5 105 R 3.046(yr)-.135 G .796(esults with an) -3.046 F 3.046(yo)-.135 G 3.046(ft)-3.046 G .796(he charac-)-3.046 F (ters)72 116 Q(^)93.6 131 Q/F1 9/Times-Bold@0 SF(.)9 E F0 9($[*\\)9 G (read the section on `)72 146 Q(`Special Characters')-.666 E('.\))-.666 E/F2 9/Times-Italic@0 SF(Ed)94.5 160.3 Q F0(pro)3.487 E 1.237 (vides a shorthand for repeating a conte)-.135 F(xt)-.135 E 1.712 (search for the same string.)72 171.3 R -.135(Fo)6.212 G 3.962(re).135 G 1.712(xample, the)-4.097 F F2(ed)3.962 E F0(line)3.962 E(number)72 182.3 Q(/string/)93.6 197.3 Q .485(will \214nd the ne)72 212.3 R .485 (xt occurrence of `)-.135 F(`string')-.666 E 2.735('. It)-.666 F .485 (often hap-)2.735 F .374 (pens that this is not the desired line, so the search must)72 223.3 R (be repeated.)72 234.3 Q(This can be done by typing merely)4.5 E(//)93.6 249.3 Q .475(This shorthand stands for `)72 264.3 R .475 (`the most recently used con-)-.666 F(te)72 275.3 Q .521(xt search e) -.135 F(xpression.)-.135 E 4.103 -.666('' I)-.63 H 2.771(tc).666 G .521 (an also be used as the \214rst)-2.771 F (string of the substitute command, as in)72 286.3 Q (/string1/s//string2/)93.6 301.3 Q 1.452(which will \214nd the ne)72 316.3 R 1.451(xt occurrence of `)-.135 F(`string1')-.666 E 3.701('a) -.666 G(nd)-3.701 E .853(replace it by `)72 327.3 R(`string2')-.666 E 3.103('. This)-.666 F .853(can sa)3.103 F 1.123 -.135(ve a l)-.18 H .854 (ot of typing.).135 F(Similarly)72 338.3 Q(??)93.6 353.3 Q(means `)72 368.3 Q(`scan backw)-.666 E(ards for the same e)-.09 E(xpression.)-.135 E -.666('')-.63 G F1(Change and Insert)72 390.3 Q/F3 9/Symbol SF(-)2.25 E F1 -.567(``)2.25 G(c').567 E 2.25('a)-.567 G(nd `)-2.25 E(`i')-.567 E (')-.567 E F0(This section discusses the)94.5 404.6 Q F2 -.135(ch)2.25 G (ang).135 E(e)-.09 E F0(command)2.25 E(c)93.6 419.6 Q 1.218 (which is used to change or replace a group of one or)72 434.6 R (more lines, and the)72 445.6 Q F2(insert)2.25 E F0(command)2.25 E(i) 93.6 460.6 Q 2.113(which is used for inserting a group of one or more)72 475.6 R(lines.)72 486.6 Q -.666(``)94.5 500.9 S(Change').666 E (', written as)-.666 E(c)93.6 515.9 Q .161 (is used to replace a number of lines with dif)72 530.9 R .161 (ferent lines,)-.225 F 1.933(which are typed in at the terminal.)72 541.9 R -.135(Fo)6.433 G 4.183(re).135 G 1.933(xample, to)-4.318 F 2.425 (change lines `)72 552.9 R(`)-.666 E F1(.)A F0(+1')A 4.675('t)-.666 G 2.425(hrough `)-4.675 F(`$')-.666 E 4.675('t)-.666 G 4.675(os)-4.675 G 2.424(omething else,)-4.675 F(type)72 563.9 Q(.+1,$c)95.85 578.9 Q 2.25 (...)95.85 589.9 S F2(type the lines of te)A(xt you want her)-.18 E(e) -.333 E F0 2.25(...)2.25 G F1(.)95.85 600.9 Q F0 .692 (The lines you type between the `)72 615.9 R(`c')-.666 E 2.942('c)-.666 G .692(ommand and the)-2.942 F -.666(``)72 626.9 S F1(.).666 E F0 3.117 -.666('' w)D 1.785(ill tak).666 F 4.035(et)-.09 G 1.785 (he place of the original lines between)-4.035 F .411 (start line and end line.)72 637.9 R .412 (This is most useful in replacing)4.911 F 2.25(al)72 648.9 S(ine or se) -2.25 E -.135(ve)-.225 G(ral lines which ha).135 E .27 -.135(ve e)-.18 H (rrors in them.).135 E .218(If only one line is speci\214ed in the `) 94.5 663.2 R(`c')-.666 E 2.468('c)-.666 G(ommand,)-2.468 E .046 (then just that line is replaced.)72 674.2 R(\(Y)4.546 E .046 (ou can type in as man)-.99 F(y)-.135 E .182 (replacement lines as you lik)72 685.2 R 2.432(e.\) Notice)-.09 F .182 (the use of `)2.432 F(`)-.666 E F1(.)A F0 1.513 -.666('' t)D(o).666 E 1.036(end the input)72 696.2 R F3(-)3.286 E F0 1.036(this w)3.286 F 1.036(orks just lik)-.09 F 3.287(et)-.09 G 1.037(he `)-3.287 F(`)-.666 E F1(.)A F0 2.369 -.666('' i)D 3.287(nt).666 G 1.037(he ap-)-3.287 F .111 (pend command and must appear by itself on a ne)72 707.2 R 2.36(wl)-.225 G(ine.)-2.36 E 1.523(If no line number is gi)72 718.2 R -.135(ve)-.225 G 1.524(n, line dot is replaced.).135 F(The)6.024 E -.225(va)72 729.2 S (lue of dot is set to the last line you typed in.).225 E -.666(``)324.9 105 S(Insert').666 E 2.25('i)-.666 G 2.25(ss)-2.25 G(imilar to append) -2.25 E F3(-)2.25 E F0(for instance)2.25 E(/string/i)324 120 Q 2.25(...) 324 131 S F2(type the lines to be inserted her)A(e)-.333 E F0 2.25(...) 2.25 G F1(.)324 142 Q F0 .908(will insert the gi)302.4 157 R -.135(ve) -.225 G 3.158(nt).135 G -.135(ex)-3.158 G(t).135 E F2(befor)3.158 E(e) -.333 E F0 .908(the ne)3.158 F .908(xt line that con-)-.135 F .309 (tains `)302.4 168 R(`string')-.666 E 2.559('. The)-.666 F(te)2.559 E .309(xt between `)-.135 F(`i')-.666 E 2.559('a)-.666 G .309(nd `)-2.559 F(`)-.666 E F1(.)A F0 1.641 -.666('' i)D(s).666 E F2(insert-)2.559 E .347(ed befor)302.4 179 R(e)-.333 E F0 .347(the speci\214ed line.)2.597 F .346(If no line number is speci-)4.847 F(\214ed dot is used.)302.4 190 Q(Dot is set to the last line inserted.)4.5 E F1(Exer)302.4 212 Q (cise 7:)-.162 E F0 -.666(``)324.9 226.3 S(Change').666 E 3.223('i)-.666 G 3.223(sr)-3.223 G .973(ather lik)-3.223 F 3.223(eac)-.09 G .974 (ombination of delete)-3.223 F(follo)302.4 237.3 Q(wed by insert.)-.225 E(Experiment to v)4.5 E(erify that)-.135 E F2(start, end)324 252.3 Q F0 (d)2.25 E(i)324 263.3 Q F2 2.25(...t)326.25 274.3 S -.18(ex)-2.25 G 2.25 (t...).18 G F1(.)324 285.3 Q F0(is almost the same as)302.4 300.3 Q F2 (start, end)324 315.3 Q F0(c)2.25 E F2 2.25(...t)326.25 326.3 S -.18(ex) -2.25 G 2.25(t...).18 G F1(.)324 337.3 Q F0 .432(These are not)302.4 352.3 R F2(pr)2.682 E(ecisely)-.333 E F0 .432(the same if line `)2.682 F (`$')-.666 E 2.682('g)-.666 G .432(ets delet-)-2.682 F 2.25(ed. Check) 302.4 363.3 R(this out.)2.25 E(What is dot?)4.5 E 1.586 (Experiment with `)324.9 377.6 R(`a')-.666 E 3.836('a)-.666 G 1.586 (nd `)-3.836 F(`i')-.666 E 1.586(', to see that the)-.666 F(y)-.135 E (are similar)302.4 388.6 Q 2.25(,b)-.36 G(ut not the same.)-2.43 E -.99 (Yo)4.5 G 2.25(uw).99 G(ill observ)-2.25 E 2.25(et)-.135 G(hat)-2.25 E F2(line\211number)324 403.6 Q F0(a)2.25 E 2.25(...)324 414.6 S F2(te)A (xt)-.18 E F0 2.25(...)2.25 G F1(.)324 425.6 Q F0(appends)302.4 440.6 Q F2(after)2.25 E F0(the gi)2.25 E -.135(ve)-.225 G 2.25(nl).135 G (ine, while)-2.25 E F2(line\211number)324 455.6 Q F0(i)2.25 E 2.25(...) 324 466.6 S F2(te)A(xt)-.18 E F0 2.25(...)2.25 G F1(.)324 477.6 Q F0 (inserts)302.4 492.6 Q F2(befor)2.682 E(e)-.333 E F0 2.681(it. Observ) 2.681 F 2.681(et)-.135 G .431(hat if no line number is gi)-2.681 F(v-) -.225 E .342(en, `)302.4 503.6 R(`i')-.666 E 2.592('i)-.666 G .342 (nserts before line dot, while `)-2.592 F(`a')-.666 E 2.592('a)-.666 G .342(ppends after)-2.592 F(line dot.)302.4 514.6 Q F1(Mo)302.4 536.6 Q (ving text ar)-.09 E(ound: the `)-.162 E(`m')-.567 E 2.25('c)-.567 G (ommand)-2.25 E F0 .404(The mo)324.9 550.9 R .674 -.135(ve c)-.135 H .404(ommand `).135 F(`m')-.666 E 2.654('i)-.666 G 2.654(su)-2.654 G .404 (sed for cutting and)-2.654 F(pasting)302.4 561.9 Q F3(-)3.631 E F0 1.381(it lets you mo)3.631 F 1.651 -.135(ve a g)-.135 H 1.381 (roup of lines from one).135 F .563(place to another in the b)302.4 572.9 R(uf)-.18 E(fer)-.225 E 5.062(.S)-.495 G .562(uppose we w)-5.062 F .562(ant to put)-.09 F .41(the \214rst three lines of the b)302.4 583.9 R(uf)-.18 E .411(fer at the end instead.)-.225 F -.72(We)4.911 G (could do it by saying:)302.4 594.9 Q(1,3w temp)324 609.9 Q($r temp)324 620.9 Q(1,3d)324 631.9 Q 1.01(\(Do you see wh)302.4 646.9 R 3.26(y?\) b) -.045 F 1.009(ut we can do it a lot easier with)-.18 F(the `)302.4 657.9 Q(`m')-.666 E 2.25('c)-.666 G(ommand:)-2.25 E(1,3m$)324 672.9 Q (The general case is)302.4 687.9 Q F2(start line)324 702.9 Q 2.25(,e) -.09 G(nd line)-2.25 E F0(m)2.25 E F2(after this line)2.25 E F0 1.585 (Notice that there is a third line to be speci\214ed)302.4 717.9 R F3(-) 3.835 E F0(the)3.835 E 1.599(place where the mo)302.4 728.9 R -.135(ve) -.135 G 3.849(ds).135 G(tuf)-3.849 E 3.849(fg)-.225 G 1.599(ets put.) -3.849 F 1.599(Of course the)6.099 F EP %%Page: 8 8 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893889>279 58 S .366 (lines to be mo)72 105 R -.135(ve)-.135 G 2.616(dc).135 G .366 (an be speci\214ed by conte)-2.616 F .366(xt searches;)-.135 F (if we had)72 116 Q(First paragraph)93.6 131 Q 2.25(...)93.6 142 S (end of \214rst paragraph.)93.6 153 Q(Second paragraph)93.6 164 Q 2.25 (...)93.6 175 S(end of second paragraph.)93.6 186 Q(we could re)72 201 Q -.135(ve)-.225 G(rse the tw).135 E 2.25(op)-.09 G(aragraphs lik)-2.25 E 2.25(et)-.09 G(his:)-2.25 E(/Second/,/second/m/First/)93.6 216 Q/F1 9 /Symbol SF(-)A F0(1)A 1.249(Notice the `)72 231 R(`)-.666 E F1(-)A F0 (1')A(')-.666 E F1(-)3.499 E F0 1.248(the mo)3.498 F -.135(ve)-.135 G 3.498(dt).135 G -.135(ex)-3.498 G 3.498(tg).135 G(oes)-3.498 E/F2 9 /Times-Italic@0 SF(after)3.498 E F0 1.248(the line)3.498 F 2.25 (mentioned. Dot)72 242 R(gets set to the last line mo)2.25 E -.135(ve) -.135 G(d.).135 E/F3 9/Times-Bold@0 SF(The global commands `)72 264 Q (`g')-.567 E 2.25('a)-.567 G(nd `)-2.25 E(`v')-.567 E(')-.567 E F0(The) 94.5 278.3 Q F2(global)2.716 E F0 .467(command `)2.717 F(`g')-.666 E 2.717('i)-.666 G 2.717(su)-2.717 G .467(sed to e)-2.717 F -.135(xe)-.135 G .467(cute one).135 F 1.204(or more)72 289.3 R F2(ed)3.454 E F0 1.203 (commands on all those lines in the b)3.454 F(uf)-.18 E(fer)-.225 E (that match some speci\214ed string.)72 300.3 Q -.135(Fo)4.5 G 2.25(re) .135 G(xample)-2.385 E(g/peling/p)93.6 315.3 Q (prints all lines that contain `)72 330.3 Q(`peling')-.666 E 2.25 ('. More)-.666 F(usefully)2.25 E(,)-.585 E(g/peling/s//pelling/gp)93.6 345.3 Q(mak)72 360.3 Q 2.439(es the substitution e)-.09 F -.135(ve)-.225 G 2.439(rywhere on the line, then).135 F(prints each corrected line.)72 371.3 Q(Compare this to)4.5 E(1,$s/peling/pelling/gp)93.6 386.3 Q 2.479 (which only prints the last line substituted.)72 401.3 R(Another)6.978 E 2.086(subtle dif)72 412.3 R 2.087(ference is that the `)-.225 F(`g') -.666 E 4.337('c)-.666 G 2.087(ommand does not)-4.337 F(gi)72 423.3 Q .295 -.135(ve a `)-.225 H(`?')-.531 E 2.275('i)-.666 G 2.275(f`)-2.275 G (`peling')-2.941 E 2.275('i)-.666 G 2.275(sn)-2.275 G .024 (ot found where the `)-2.275 F(`s')-.666 E 2.274('c)-.666 G(om-)-2.274 E (mand will.)72 434.3 Q .432(There may be se)94.5 448.6 R -.135(ve)-.225 G .432(ral commands \(including `).135 F(`a')-.666 E(',)-.666 E -.666 (``)72 459.6 S(c').666 E 3.714('`)-.666 G(`i')-4.38 E 3.714('`)-.666 G (`r')-4.38 E 1.464(', `)-.666 F(`w')-.666 E 1.464(', b)-.666 F 1.463 (ut not `)-.18 F(`g')-.666 E 1.463('\); in that case, e)-.666 F -.135 (ve)-.225 G(ry).135 E(line e)72 470.6 Q (xcept the last must end with a backslash `)-.135 E(`\\')-.666 E(':) -.666 E(g/xxx/)93.6 485.6 Q F3(.)A F0(\2111s/abc/def/\\)A F3(.)93.6 496.6 Q F0(+2s/ghi/jkl/\\)A F3(.)93.6 507.6 Q F0(\2112,)A F3(.)A F0(p)A (mak)72 522.6 Q 1.333 (es changes in the lines before and after each line)-.09 F (that contains `)72 533.6 Q(`xxx')-.666 E (', then prints all three lines.)-.666 E 1.588(The `)94.5 547.9 R(`v') -.666 E 3.838('c)-.666 G 1.587(ommand is the same as `)-3.838 F(`g') -.666 E 1.587(', e)-.666 F(xcept)-.135 E .336(that the commands are e)72 558.9 R -.135(xe)-.135 G .336(cuted on e).135 F -.135(ve)-.225 G .336 (ry line that does).135 F F2(not)72 569.9 Q F0(match the string follo) 2.25 E(wing `)-.225 E(`v')-.666 E(':)-.666 E(v/ /d)93.6 584.9 Q (deletes e)72 599.9 Q -.135(ve)-.225 G (ry line that does not contain a blank.).135 E F3(Special Characters)72 621.9 Q F0 -.99(Yo)94.5 636.2 S 2.522(um).99 G .271(ay ha)-2.522 F .541 -.135(ve n)-.18 H .271(oticed that things just don').135 F 2.521(tw) -.162 G(ork)-2.611 E 2.036(right when you used some characters lik)72 647.2 R 4.287(e`)-.09 G(`.)-4.953 E -.666('')-.63 G 4.287(,`).666 G(`*') -4.953 E(',)-.666 E -.666(``)72 658.2 S($').666 E 1.107 (', and others in conte)-.666 F 1.107(xt searches and the substitute) -.135 F 3.074(command. The)72 669.2 R .824(reason is rather comple)3.074 F .824(x, although the)-.135 F .998(cure is simple.)72 680.2 R (Basically)5.498 E(,)-.585 E F2(ed)3.248 E F0 .998 (treats these characters as)3.248 F .595 (special, with special meanings.)72 691.2 R -.135(Fo)5.095 G 2.845(ri) .135 G(nstance,)-2.845 E F2 .595(in a con-)2.845 F(te)72 702.2 Q .399 (xt sear)-.18 F .669 -.135(ch o)-.333 H 2.649(rt).135 G .399(he \214r) -2.649 F .399(st string of the substitute command)-.09 F(only)72 713.2 Q (,)-.495 E F0(/x)93.6 728.2 Q F3(.)A F0(y/)A .837(means `)302.4 105 R .837(`a line with an)-.666 F(x,)5.337 E F2 .837(any c)3.087 F(har)-.135 E(acter)-.135 E(,)-.999 E F0 .837(and a y)3.087 F -.63(,')-.585 G(') -.036 E F2(not)3.087 E F0 .724(just `)302.4 116 R .724 (`a line with an x, a period, and a y)-.666 F -.63(.')-.585 G 5.223('A) -.036 G(complete)-2.25 E 1.433 (list of the special characters that can cause trouble is)302.4 127 R (the follo)302.4 138 Q(wing:)-.225 E(^)324 153 Q F3(.)9 E F0 9($[*\\)9 G F2 -.828(Wa)302.4 168 S(rning:).828 E F0 2.09 (The backslash character \\ is special to)4.341 F F2(ed.)4.34 E F0 -.135 (Fo)302.4 179 S 2.976(rs).135 G(afety')-2.976 E 2.976(ss)-.495 G(ak) -2.976 E .726(e, a)-.09 F -.18(vo)-.18 G .726(id it where possible.).18 F .726(If you ha)5.226 F -.135(ve)-.18 G .314 (to use one of the special characters in a substitute com-)302.4 190 R .887(mand, you can turn of)302.4 201 R 3.138(fi)-.225 G .888 (ts magic meaning temporarily)-3.138 F (by preceding it with the backslash.)302.4 212 Q(Thus)4.5 E(s/\\\\\\)324 227 Q F3(.)A F0(\\*/backslash dot star/)A(will change `)302.4 242 Q(`\\) -.666 E F3(.)A F0(*')A 2.25('i)-.666 G(nto `)-2.25 E (`backslash dot star')-.666 E('.)-.666 E 1.829 (Here is a hurried synopsis of the other special)324.9 256.3 R 2.929 (characters. First,)302.4 267.3 R .679(the circum\215e)2.929 F 2.929(x`) -.135 G 2.929(`^')-3.595 G 2.929('s)-3.595 G .679(igni\214es the be-) -2.929 F(ginning of a line.)302.4 278.3 Q(Thus)4.5 E(/^string/)324 293.3 Q .631(\214nds `)302.4 308.3 R(`string')-.666 E 2.881('o)-.666 G .631 (nly if it is at the be)-2.881 F .63(ginning of a line: it)-.135 F (will \214nd)302.4 319.3 Q(string)324 334.3 Q -.18(bu)302.4 349.3 S 2.25 (tn).18 G(ot)-2.25 E(the string...)324 364.3 Q .71(The dollar)302.4 379.3 R .71(-sign `)-.18 F(`$')-.666 E 2.96('i)-.666 G 2.96(sj)-2.96 G .71(ust the opposite of the circum-)-2.96 F<8d65>302.4 390.3 Q (x; it means the end of a line:)-.135 E(/string$/)324 405.3 Q 1.147 (will only \214nd an occurrence of `)302.4 420.3 R(`string')-.666 E 3.396('t)-.666 G 1.146(hat is at the)-3.396 F(end of some line.)302.4 431.3 Q(This implies, of course, that)4.5 E(/^string$/)324 446.3 Q (will \214nd only a line that contains just `)302.4 461.3 Q(`string') -.666 E(', and)-.666 E(/^)324 476.3 Q F3(.)A F0($/)A (\214nds a line containing e)302.4 491.3 Q(xactly one character)-.135 E (.)-.495 E 4.002(The character `)324.9 505.6 R(`)-.666 E F3(.)A F0 -.666 ('')C 6.252(,a).666 G 6.252(sw)-6.252 G 6.252(em)-6.252 G 4.002 (entioned abo)-6.252 F -.135(ve)-.135 G(,).135 E(matches an)302.4 516.6 Q(ything;)-.135 E(/x)324 531.6 Q F3(.)A F0(y/)A(matches an)302.4 546.6 Q 2.25(yo)-.135 G(f)-2.25 E(x+y)324 561.6 Q(x\211y)324 572.6 Q 2.25(xy)324 583.6 S(x)324 594.6 Q F3(.)A F0(y)A .171 (This is useful in conjunction with `)302.4 609.6 R(`*')-.666 E .171 (', which is a repe-)-.666 F 1.036(tition character; `)302.4 620.6 R (`a*')-.666 E 3.286('i)-.666 G 3.286(sas)-3.286 G 1.036(horthand for `) -3.286 F(`an)-.666 E 3.287(yn)-.135 G(umber)-3.287 E 2.411(of a')302.4 631.6 R(s,)-.495 E 3.743 -.666('' s)-.63 H 4.661(o`).666 G(`)-5.327 E F3 (.)A F0(*')A 4.661('m)-.666 G 2.411(atches an)-4.661 F 4.661(yn)-.135 G 2.411(umber of an)-4.661 F(ythings.)-.135 E(This is used lik)302.4 642.6 Q 2.25(et)-.09 G(his:)-2.25 E(s/)324 657.6 Q F3(.)A F0(*/stuf)A(f/)-.225 E(which changes an entire line, or)302.4 672.6 Q(s/)324 687.6 Q F3(.)A F0(*,//)A .064 (which deletes all characters in the line up to and includ-)302.4 702.6 R .55(ing the last comma.)302.4 713.6 R .55(\(Since `)5.05 F(`)-.666 E F3(.)A F0(*')A 2.8<278c>-.666 G .55(nds the longest pos-)-2.8 F (sible match, this goes up to the last comma.\))302.4 724.6 Q EP %%Page: 9 9 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<893989>279 58 S -.666(``)94.5 105 S ([').666 E 3.749('i)-.666 G 3.749(su)-3.749 G 1.499(sed with `)-3.749 F (`]')-.666 E 3.75('t)-.666 G 3.75(of)-3.75 G 1.5(orm `)-3.75 F 1.5 (`character class-)-.666 F(es')72 116 Q('; for e)-.666 E(xample,)-.135 E (/[1234567890]/)93.6 131 Q .342(matches an)72 146 R 2.591(ys)-.135 G .341(ingle digit _ an)-2.591 F 2.591(yo)-.135 G .341 (ne of the characters in-)-2.591 F(side the braces will cause a match.) 72 157 Q(Finally)94.5 171.3 Q 2.687(,t)-.585 G .437(he `)-2.687 F(`&') -.666 E 2.687('i)-.666 G 2.687(sa)-2.687 G .437 (nother shorthand character -)-2.687 F 1.811 (it is used only on the right-hand part of a substitute)72 182.3 R 1.288 (command where it means `)72 193.3 R(`whate)-.666 E -.135(ve)-.225 G 3.538(rw).135 G 1.289(as matched on)-3.628 F .539(the left-hand side')72 204.3 R 2.789('. It)-.666 F .539(is used to sa)2.789 F .809 -.135(ve t) -.18 H 2.789(yping. Suppose).135 F(the current line contained)72 215.3 Q (No)93.6 230.3 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time)-2.25 E .578 (and we w)72 245.3 R .578(anted to put parentheses around it.)-.09 F 2.018 -.72(We c)5.078 H(ould).72 E .163(just retype the line, b)72 256.3 R .163(ut this is tedious.)-.18 F .162(Or we could say)4.663 F(s/^/\(/) 93.6 271.3 Q(s/$/\)/)93.6 282.3 Q .976(using our kno)72 297.3 R .976 (wledge of `)-.225 F(`^')-.666 E 3.226('a)-.666 G .976(nd `)-3.226 F (`$')-.666 E 3.226('. But)-.666 F .976(the easiest)3.226 F -.09(wa)72 308.3 S 2.25(yu).09 G(ses the `)-2.25 E(`&')-.666 E(':)-.666 E(s/)93.6 323.3 Q/F1 9/Times-Bold@0 SF(.)A F0(*/\(&\)/)A .055(This says `)72 338.3 R .055(`match the whole line, and replace it by itself)-.666 F .894 (surrounded by parens.)72 349.3 R 4.476 -.666('' T)-.63 H .894(he `).666 F(`&')-.666 E 3.144('c)-.666 G .895(an be used se)-3.144 F -.135(ve) -.225 G(ral).135 E(times in a line; consider using)72 360.3 Q(s/)93.6 375.3 Q F1(.)A F0 2.25(*/&? &!!/)B(to produce)72 390.3 Q(No)93.6 405.3 Q 2.25(wi)-.225 G 2.25(st)-2.25 G(he time?)-2.25 E(No)4.5 E 2.25(wi)-.225 G 2.25(st)-2.25 G(he time!!)-2.25 E 1.477 -.72(We d)94.5 423.6 T(on').72 E 2.287(th)-.162 G -2.025 -.18(av e)-2.287 H .037 (to match the whole line, of course:)2.467 F(if the b)72 434.6 Q(uf)-.18 E(fer contains)-.225 E(the end of the w)93.6 449.6 Q(orld)-.09 E (we could type)72 464.6 Q(/w)93.6 479.6 Q(orld/s//& is at hand/)-.09 E (to produce)72 494.6 Q(the end of the w)93.6 509.6 Q(orld is at hand) -.09 E(Observ)72 524.6 Q 2.994(et)-.135 G .744(his e)-2.994 F .744 (xpression carefully)-.135 F 2.994(,f)-.585 G .745(or it illustrates ho) -2.994 F(w)-.225 E 2.501(to tak)72 535.6 R 4.751(ea)-.09 G(dv)-4.751 E 2.501(antage of)-.225 F/F2 9/Times-Italic@0 SF(ed)4.751 E F0 2.501 (to sa)4.751 F 2.771 -.135(ve t)-.18 H 4.751(yping. The).135 F(string) 4.751 E -.666(``)72 546.6 S(/w).666 E(orld/')-.09 E 4.127('f)-.666 G 1.877(ound the desired line; the shorthand `)-4.127 F(`//')-.666 E(') -.666 E .375(found the same w)72 557.6 R .375 (ord in the line; and the `)-.09 F(`&')-.666 E 2.624('s)-.666 G -2.025 -.18(av e)-2.624 H 2.624(du).18 G(s)-2.624 E(from typing it ag)72 568.6 Q(ain.)-.045 E 1.434(The `)94.5 582.9 R(`&')-.666 E 3.684('i)-.666 G 3.684(sas)-3.684 G 1.435(pecial character only within the)-3.684 F 1.065 (replacement te)72 593.9 R 1.064(xt of a substitute command, and has no) -.135 F .291(special meaning else)72 604.9 R 2.541(where. W)-.225 F 2.541(ec)-.72 G .291(an turn of)-2.541 F 2.542(ft)-.225 G .292 (he special)-2.542 F(meaning of `)72 615.9 Q(`&')-.666 E 2.25('b)-.666 G 2.25(yp)-2.25 G(receding it with a `)-2.25 E(`\\')-.666 E(':)-.666 E (s/ampersand/\\&/)93.6 630.9 Q .007(will con)72 645.9 R -.135(ve)-.36 G .007(rt the w).135 F .007(ord `)-.09 F(`ampersand')-.666 E 2.257('i) -.666 G .006(nto the literal sym-)-2.257 F(bol `)72 656.9 Q(`&')-.666 E 2.25('i)-.666 G 2.25(nt)-2.25 G(he current line.)-2.25 E F1 (Summary of Commands and Line Numbers)302.4 105 Q F0 1.579 (The general form of)324.9 119.3 R F2(ed)3.829 E F0 1.58 (commands is the com-)3.83 F .415 (mand name, perhaps preceded by one or tw)302.4 130.3 R 2.665(ol)-.09 G .415(ine num-)-2.665 F .951(bers, and, in the case of)302.4 141.3 R F2 1.131 -.09(e, r)3.201 H F0(and)3.291 E F2 -.666(w,)3.201 G F0(follo) 3.867 E .952(wed by a \214le)-.225 F 2.979(name. Only)302.4 152.3 R .728 (one command is allo)2.978 F .728(wed per line, b)-.225 F .728(ut a)-.18 F F2(p)2.978 E F0 1.126(command may follo)302.4 163.3 R 3.376(wa)-.225 G 1.396 -.135(ny o)-3.376 H 1.126(ther command \(e).135 F 1.127(xcept for) -.135 F F2 .18 -.09(e, r)302.4 174.3 T 2.25(,w)-.909 G F0(and)A F2(q\).) 2.25 E 2.663(a\()302.4 196.3 S(append\))-2.663 E F0 .413 (Add lines to the b)2.663 F(uf)-.18 E .412(fer \(at line dot, unless a) -.225 F(dif)302.4 207.3 Q 1.599 (ferent line is speci\214ed\). Appending continues until)-.225 F -.666 (``)302.4 218.3 S F1(.).666 E F0 4.5 -.666('' i)D 3.168(st).666 G .918 (yped on a ne)-3.168 F 3.167(wl)-.225 G 3.167(ine. Dot)-3.167 F .917 (is set to the last line)3.167 F(appended.)302.4 229.3 Q F2 3.58(c\() 302.4 244.3 S -.135(ch)-3.58 G(ang).135 E(e\))-.09 E F0 1.33 (Change the speci\214ed lines to the ne)3.58 F 3.58(wt)-.225 G -.135(ex) -3.58 G(t).135 E .52(which follo)302.4 255.3 R 2.77(ws. The)-.225 F(ne) 2.77 E 2.77(wl)-.225 G .52(ines are terminated by a `)-2.77 F(`)-.666 E F1(.)A F0 -.666('')C(.).666 E .694 (If no lines are speci\214ed, replace line dot.)302.4 266.3 R .694 (Dot is set to)5.194 F(last line changed.)302.4 277.3 Q F2 2.851(d\() 302.4 292.3 S(delete\))-2.851 E F0 .601(Delete the lines speci\214ed.) 2.851 F .601(If none are speci-)5.101 F 1.585(\214ed, delete line dot.) 302.4 303.3 R 1.586(Dot is set to the \214rst undeleted)6.086 F .928 (line, unless `)302.4 314.3 R(`$')-.666 E 3.178('i)-.666 G 3.178(sd) -3.178 G .928(eleted, in which case dot is set to)-3.178 F -.666(``) 302.4 325.3 S($').666 E('.)-.666 E F2 4.19(e\()302.4 340.3 S(edit\)) -4.19 E F0 1.94(Edit ne)4.19 F 4.19<778c>-.225 G 4.19(le. An)-4.19 F 4.19(yp)-.135 G(re)-4.19 E 1.94(vious contents of the)-.225 F -.18(bu) 302.4 351.3 S -.225(ff).18 G .535(er are thro).225 F .535(wn a)-.225 F -.09(wa)-.135 G 1.705 -.585(y, s).09 H 2.785(oi).585 G .535(ssue a) -2.785 F F2(w)2.784 E F0 .534(beforehand if you)2.784 F -.09(wa)302.4 362.3 S(nt to sa).09 E .27 -.135(ve t)-.18 H(hem.).135 E F2 2.818(f\() 302.4 377.3 S(\214le\))-2.818 E F0 .568(Print remembered \214lename.) 2.818 F .568(If a name follo)5.068 F(ws)-.225 E F2(f)2.818 E F0 (the remembered name will be set to it.)302.4 388.3 Q F2 3.317(g\()302.4 403.3 S 1.067(global\) g/---/commands)-3.317 F F0 1.066(will e)3.317 F -.135(xe)-.135 G 1.066(cute the commands).135 F .037 (on those lines that contain `)302.4 414.3 R(`---')-.666 E .037 (', which can be an)-.666 F 2.287(yc)-.135 G(on-)-2.287 E(te)302.4 425.3 Q(xt search e)-.135 E(xpression.)-.135 E F2 2.792(i\()302.4 440.3 S (insert\))-2.792 E F0 .542 (Insert lines before speci\214ed line \(or dot\) until)2.792 F 2.887(a`) 302.4 451.3 S(`)-3.553 E F1(.)A F0 1.969 -.666('' i)D 2.887(st).666 G .638(yped on a ne)-2.887 F 2.888(wl)-.225 G 2.888(ine. Dot)-2.888 F .638 (is set to last line in-)2.888 F(serted.)302.4 462.3 Q F2 3.167(m\() 302.4 477.3 S(mo)-3.167 E(ve\))-.09 E F0(Mo)3.167 E 1.187 -.135(ve l) -.135 H .917(ines speci\214ed to after the line named).135 F(after)302.4 488.3 Q F2(m.)2.25 E F0(Dot is set to the last line mo)4.5 E -.135(ve) -.135 G(d.).135 E F2 3.483(p\()302.4 503.3 S(print\))-3.483 E F0 1.233 (Print speci\214ed lines.)3.483 F 1.233(If none speci\214ed, print)5.733 F 1.22(line dot.)302.4 514.3 R 3.47(As)5.72 G 1.22 (ingle line number is equi)-3.47 F -.225(va)-.225 G 1.22(lent to `).225 F(`line-)-.666 E 1.739(number p')302.4 525.3 R 3.989('. A)-.666 F 1.739 (single ne)3.989 F 1.739(wline prints `)-.225 F(`)-.666 E F1(.)A F0(+1') A 1.74(', the ne)-.666 F(xt)-.135 E(line.)302.4 536.3 Q F2 2.25(q\() 302.4 551.3 S(quit\))-2.25 E F0(Exit from ed.)2.25 E -.36(Wi)4.5 G (pes out all te).36 E(xt in b)-.135 E(uf)-.18 E(fer!!)-.225 E F2 2.938 (r\()302.4 566.3 S -.333(re)-2.938 G(ad\)).333 E F0 .688 (Read a \214le into b)2.938 F(uf)-.18 E .687 (fer \(at end unless speci\214ed)-.225 F(else)302.4 577.3 Q (where.\) Dot set to last line read.)-.225 E F2 2.961(s\()302.4 592.3 S .711(substitute\) s/string1/string2/)-2.961 F F0 .711 (will substitute the char)2.961 F(-)-.18 E .543 (acters of `string2' for `string1' in speci\214ed lines.)302.4 603.3 R .543(If no)5.043 F 1.131(line is speci\214ed, mak)302.4 614.3 R 3.381 (es)-.09 G 1.131(ubstitution in line dot.)-3.381 F 1.131(Dot is)5.631 F .185(set to last line in which a substitution took place, which)302.4 625.3 R 2.455(means that if no substitution took place, dot is not)302.4 636.3 R(changed.)302.4 647.3 Q F2(s)4.956 E F0 .456 (changes only the \214rst occurrence of string1)2.706 F .306 (on a line; to change all of them, type a `)302.4 658.3 R(`g')-.666 E 2.556('a)-.666 G .306(fter the \214-)-2.556 F(nal slash.)302.4 669.3 Q F2 3.69(v\()302.4 684.3 S -.18(ex)-3.69 G 1.44(clude\) v/---/commands) .18 F F0 -.135(exe)3.69 G 1.44(cutes `).135 F(`commands')-.666 E 3.69 ('o)-.666 G(n)-3.69 E(those lines that)302.4 695.3 Q F2(do not)2.25 E F0 (contain `)2.25 E(`---')-.666 E('.)-.666 E F2 5.051(w\()302.4 710.3 S (write\))-5.051 E F0 2.801(Write out b)5.051 F(uf)-.18 E 2.802 (fer onto a \214le.)-.225 F 2.802(Dot is not)7.302 F(changed.)302.4 721.3 Q EP %%Page: 10 10 %%BeginPageSetup BP %%EndPageSetup /F0 9/Times-Roman@0 SF(-)0 11 Q 2.25<8931>276.75 58 S 2.25<3089>-2.25 G /F1 9/Times-Italic@0 SF .729(.= \(dot value\))72 105 R F0 .728(Print v) 2.978 F .728(alue of dot.)-.225 F(\(`)5.228 E(`=')-.666 E 2.978('b)-.666 G 2.978(yi)-2.978 G .728(tself prints)-2.978 F(the v)72 116 Q(alue of `) -.225 E(`$')-.666 E('.\))-.666 E F1 2.25(!\()72 131 S(tempor)-2.25 E (ary escape\))-.135 E F0(Ex)78.75 142 Q (ecute this line as a UNIX command.)-.135 E F1(/-----/)72 157 Q F0 (Conte)2.99 E .74(xt search.)-.135 F .74(Search for ne)5.24 F .741 (xt line which con-)-.135 F .078(tains this string of characters.)72 168 R .078(Print it.)4.578 F .077(Dot is set to line)4.578 F 3.093 (where string found.)72 179 R 3.094(Search starts at `)7.593 F(`)-.666 E /F2 9/Times-Bold@0 SF(.)A F0(+1')A 3.094(', wraps)-.666 F 1.098 (around from `)72 190 R(`$')-.666 E 3.347('t)-.666 G 3.347(o1)-3.347 G 3.347(,a)-3.347 G 1.097(nd continues to dot, if neces-)-3.347 F(sary)72 201 Q(.)-.585 E F1(?-----?)72 216 Q F0(Conte)8.565 E 4.065 (xt search in re)-.135 F -.135(ve)-.225 G 4.065(rse direction.).135 F (Start)8.565 E(search at `)72 227 Q(`)-.666 E F2(.)A/F3 9/Symbol SF(-)A F0(1')A(', scan to 1, wrap around to `)-.666 E(`$')-.666 E('.)-.666 E EP %%Trailer end %%EOF