From: Tom London Date: Thu, 25 Jan 1979 12:38:28 +0000 (-0500) Subject: Bell 32V development X-Git-Tag: Bell-32V~264 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/fed84c9b42bc6a290e128ff36d3b45746f3ebcea Bell 32V development Work on file usr/lib/learn/files/L0.1d Work on file usr/lib/learn/files/L0.1a Work on file usr/lib/learn/files/L0.1b Work on file usr/lib/learn/files/L1.2a Work on file usr/lib/learn/files/L1.1a Work on file usr/lib/learn/files/L0 Work on file usr/lib/learn/files/L0.1c Work on file usr/lib/learn/files/L10.1a Work on file usr/lib/learn/files/L10.2b Work on file usr/lib/learn/files/L1.2b Work on file usr/lib/learn/files/L10.2a Work on file usr/lib/learn/files/L10.3a Work on file usr/lib/learn/files/L10.3b Work on file usr/lib/learn/files/L10.3c Work on file usr/lib/learn/files/L11.2b Work on file usr/lib/learn/files/L10.3d Work on file usr/lib/learn/files/L11.3b Work on file usr/lib/learn/files/L11.2a Work on file usr/lib/learn/files/L12.2c Work on file usr/lib/learn/files/L12.3a Work on file usr/lib/learn/files/L11.3c Work on file usr/lib/learn/files/L12.1a Work on file usr/lib/learn/files/L11.3a Work on file usr/lib/learn/files/L12.2b Work on file usr/lib/learn/files/L12.2a Work on file usr/lib/learn/files/L12.3b Work on file usr/lib/learn/files/L12.3c Work on file usr/lib/learn/files/L11.1a Work on file usr/lib/learn/files/L13.1e Work on file usr/lib/learn/files/L13.1d Work on file usr/lib/learn/files/L13.1c Work on file usr/lib/learn/files/L13.1b Work on file usr/lib/learn/files/L13.1a Work on file usr/lib/learn/files/L13.1f Work on file usr/lib/learn/files/L3.1a Work on file usr/lib/learn/files/L3.2a Work on file usr/lib/learn/files/L3.2b Work on file usr/lib/learn/files/L3.3b Work on file usr/lib/learn/files/L3.3a Work on file usr/lib/learn/files/L4.1a Work on file usr/lib/learn/files/L13.1g Work on file usr/lib/learn/files/L2.1a Work on file usr/lib/learn/files/L2.2a Work on file usr/lib/learn/files/L2.2b Work on file usr/lib/learn/files/L5.1e Work on file usr/lib/learn/files/L4.2b Work on file usr/lib/learn/files/L6.1a Work on file usr/lib/learn/files/L5.1d Work on file usr/lib/learn/files/L4.3a Work on file usr/lib/learn/files/L4.3b Work on file usr/lib/learn/files/L4.2a Work on file usr/lib/learn/files/L5.1b Work on file usr/lib/learn/files/L4.3c Work on file usr/lib/learn/files/L5.1a Work on file usr/lib/learn/files/L5.1c Work on file usr/lib/learn/files/L7.2a Work on file usr/lib/learn/files/L6.1b Work on file usr/lib/learn/files/L6.2a Work on file usr/lib/learn/files/L6.1c Work on file usr/lib/learn/files/L6.1d Work on file usr/lib/learn/files/L7.2b Work on file usr/lib/learn/files/L6.2b Work on file usr/lib/learn/files/L6.1e Work on file usr/lib/learn/files/L7.1a Work on file usr/lib/learn/files/Lxxx Work on file usr/lib/learn/files/L8.2a Work on file usr/lib/learn/files/L8.2c Work on file usr/lib/learn/files/L9.2a Work on file usr/lib/learn/files/L9.2c Work on file usr/lib/learn/files/L9.1a Work on file usr/lib/learn/files/L8.1a Work on file usr/lib/learn/files/L7.3b Work on file usr/lib/learn/files/L7.3a Work on file usr/lib/learn/files/L7.3c Work on file usr/lib/learn/files/L9.2b Work on file usr/lib/learn/files/L8.2b Work on file usr/lib/learn/editor/L10.2a Work on file usr/lib/learn/editor/L10.1b Work on file usr/lib/learn/editor/L10.3a Work on file usr/lib/learn/editor/L10.1a Work on file usr/lib/learn/editor/L1.1a Work on file usr/lib/learn/editor/L0 Work on file usr/lib/learn/editor/L10.2b Work on file usr/lib/learn/editor/L10.2c Work on file usr/lib/learn/editor/L10.3b Work on file usr/lib/learn/editor/L10.3d Work on file usr/lib/learn/editor/L11.2a Work on file usr/lib/learn/editor/L11.2b Work on file usr/lib/learn/editor/L10.3e Work on file usr/lib/learn/editor/L10.3f Work on file usr/lib/learn/editor/L10.3c Work on file usr/lib/learn/editor/L11.1a Work on file usr/lib/learn/editor/L12.1b Work on file usr/lib/learn/editor/L11.2c Work on file usr/lib/learn/editor/L12.2a Work on file usr/lib/learn/editor/L12.1a Work on file usr/lib/learn/editor/L13.1a Work on file usr/lib/learn/editor/L12.2c Work on file usr/lib/learn/editor/L12.2b Work on file usr/lib/learn/editor/L15.2a Work on file usr/lib/learn/editor/L15.1b Work on file usr/lib/learn/editor/L13.2b Work on file usr/lib/learn/editor/L14.2a Work on file usr/lib/learn/editor/L14.2b Work on file usr/lib/learn/editor/L15.2c Work on file usr/lib/learn/editor/L14.1a Work on file usr/lib/learn/editor/L13.2a Work on file usr/lib/learn/editor/L15.3b Work on file usr/lib/learn/editor/L15.1a Work on file usr/lib/learn/editor/L15.2d Work on file usr/lib/learn/editor/L15.3d Work on file usr/lib/learn/editor/L15.2b Work on file usr/lib/learn/editor/L16.2a Work on file usr/lib/learn/editor/L15.3e Work on file usr/lib/learn/editor/L17.2c Work on file usr/lib/learn/editor/L16.2c Work on file usr/lib/learn/editor/L16.1c Work on file usr/lib/learn/editor/L17.2b Work on file usr/lib/learn/editor/L16.1a Work on file usr/lib/learn/editor/L15.3f Work on file usr/lib/learn/editor/L17.2d Work on file usr/lib/learn/editor/L17.2a Work on file usr/lib/learn/editor/L16.1b Work on file usr/lib/learn/editor/L18.2a Work on file usr/lib/learn/editor/L18.2c Work on file usr/lib/learn/editor/L18.3a Work on file usr/lib/learn/editor/L18.2e Work on file usr/lib/learn/editor/L18.1a Work on file usr/lib/learn/editor/L18.2d Work on file usr/lib/learn/editor/L18.3b Work on file usr/lib/learn/editor/L19.2c Work on file usr/lib/learn/editor/L19.2e Work on file usr/lib/learn/editor/L19.2a Work on file usr/lib/learn/editor/L2.2a Work on file usr/lib/learn/editor/L19.3b Work on file usr/lib/learn/editor/L19.1a Work on file usr/lib/learn/editor/L19.2f Work on file usr/lib/learn/editor/L2.1a Work on file usr/lib/learn/editor/L19.2d Work on file usr/lib/learn/editor/L19.1b Work on file usr/lib/learn/editor/L20.2c Work on file usr/lib/learn/editor/L20.2b Work on file usr/lib/learn/editor/L20.2a Work on file usr/lib/learn/editor/L21.1b Work on file usr/lib/learn/editor/L20.1a Work on file usr/lib/learn/editor/L21.1a Work on file usr/lib/learn/editor/L3.1a Work on file usr/lib/learn/editor/L21.1c Work on file usr/lib/learn/editor/L3.1b Work on file usr/lib/learn/editor/L21.1e Work on file usr/lib/learn/editor/L21.1d Work on file usr/lib/learn/editor/L30.1b Work on file usr/lib/learn/editor/L30.2f Work on file usr/lib/learn/editor/L30.2e Work on file usr/lib/learn/editor/L30.2h Work on file usr/lib/learn/editor/L30.2d Work on file usr/lib/learn/editor/L30.2g Work on file usr/lib/learn/editor/L30.2a Work on file usr/lib/learn/editor/L30.2b Work on file usr/lib/learn/editor/L30.1a Work on file usr/lib/learn/editor/L30.2c Work on file usr/lib/learn/editor/L31.1a Work on file usr/lib/learn/editor/L32.1b Work on file usr/lib/learn/editor/L31.2b Work on file usr/lib/learn/editor/L32.1a Work on file usr/lib/learn/editor/L32.2a Work on file usr/lib/learn/editor/L31.2c Work on file usr/lib/learn/editor/L32.1c Work on file usr/lib/learn/editor/L32.2e Work on file usr/lib/learn/editor/L32.2f Work on file usr/lib/learn/editor/L33.2a Work on file usr/lib/learn/editor/L34.1a Work on file usr/lib/learn/editor/L32.2g Work on file usr/lib/learn/editor/L32.2b Work on file usr/lib/learn/editor/L34.2a Work on file usr/lib/learn/editor/L33.1a Work on file usr/lib/learn/editor/L33.2c Work on file usr/lib/learn/editor/L33.1b Work on file usr/lib/learn/editor/L32.2d Work on file usr/lib/learn/editor/L33.2b Work on file usr/lib/learn/editor/L34.2b Work on file usr/lib/learn/editor/L34.2c Work on file usr/lib/learn/editor/L34.1b Work on file usr/lib/learn/editor/L32.2c Work on file usr/lib/learn/editor/L34.2e Work on file usr/lib/learn/editor/L35.2b Work on file usr/lib/learn/editor/L35.2c Work on file usr/lib/learn/editor/L34.2d Work on file usr/lib/learn/editor/L35.2a Work on file usr/lib/learn/editor/L35.1a Work on file usr/lib/learn/editor/L34.2f Work on file usr/lib/learn/editor/L35.2d Work on file usr/lib/learn/editor/L36.1a Work on file usr/lib/learn/editor/L35.2e Work on file usr/lib/learn/editor/L36.2d Work on file usr/lib/learn/editor/L36.2c Work on file usr/lib/learn/editor/L36.2a Work on file usr/lib/learn/editor/L37.1a Work on file usr/lib/learn/editor/L36.2b Co-Authored-By: John Reiser Synthesized-from: 32v --- diff --git a/usr/lib/learn/editor/L0 b/usr/lib/learn/editor/L0 new file mode 100644 index 0000000000..c1af3e0038 --- /dev/null +++ b/usr/lib/learn/editor/L0 @@ -0,0 +1,2 @@ +#next +1.1a 10 diff --git a/usr/lib/learn/editor/L1.1a b/usr/lib/learn/editor/L1.1a new file mode 100644 index 0000000000..d822fb3d65 --- /dev/null +++ b/usr/lib/learn/editor/L1.1a @@ -0,0 +1,21 @@ +#print +This program will try to help you learn how to use the editor. +You should really know, before starting this, how to use files +and how to type. +There is a "learn files" procedure to teach you about files. +Just to review, the current directory contains some files +whose name begins with "do"; they describe something you should do. +Find out what, do that, and then type "ready". +#create ohio +#create do1 +There is a file in this +directory named for a state. +#create do2 +Change the name of that file +to 'iowa'. +#user +test ! -r ohio && test -r iowa +#log +#next +2.1a 1 +2.2a 10 diff --git a/usr/lib/learn/editor/L10.1a b/usr/lib/learn/editor/L10.1a new file mode 100644 index 0000000000..8c892ca42f --- /dev/null +++ b/usr/lib/learn/editor/L10.1a @@ -0,0 +1,32 @@ +#print +Often, what you want to do is print an entire file, +and often you don't know exactly how long it is. +There is a special abbreviation for this purpose: +the character + $ +refers to the last line in the file, and so +1,$p prints all of a file. +Here's a new file. Print it out using the editor +command 1,$p. Then do the usual w, q, and ready. +#create Ref +1,$p +w +q +#create file +New York Mets Managers + Casey Stengel + Wes Westrum + Gil Hodges + Yogi Berra + Roy McMillan +#copyin +#pipe +ed file +#user +#unpipe +#uncopyin +tail -3 .copy >X1 +#cmp X1 Ref +#log +#next +10.1b 10 diff --git a/usr/lib/learn/editor/L10.1b b/usr/lib/learn/editor/L10.1b new file mode 100644 index 0000000000..8cf203e74d --- /dev/null +++ b/usr/lib/learn/editor/L10.1b @@ -0,0 +1,39 @@ +#print +You can of course combine the various sorts +of line addresses we have been using. +Suppose the last line is line 6; then $ is +line 6, and $-1 is line 5. Thus $-1 is the +next to last line, and + 1,$-1p +prints all but the last line of a file. Again, +I'll put you in the editor: print the last three lines +of the file. End with the usual w, q, and ready. +#create Ref + Gil Hodges + Yogi Berra + Roy McMillan +89 +#create file +New York Mets Managers + Casey Stengel + Wes Westrum + Gil Hodges + Yogi Berra + Roy McMillan +#copyout +#pipe +ed file +#user +#unpipe +#uncopyout +tail -4 .ocopy >X1 +#cmp X1 Ref +#fail +I hope you realized the addresses had to be + $-2,$p +to get the last three lines. +#cmp X1 Ref +#log +#next +11.1a 10 +11.2a 5 diff --git a/usr/lib/learn/editor/L10.2a b/usr/lib/learn/editor/L10.2a new file mode 100644 index 0000000000..f60beca6a0 --- /dev/null +++ b/usr/lib/learn/editor/L10.2a @@ -0,0 +1,39 @@ +#print +Often you want to refer to the last line +of a file, and you don't know how long it is. +There is a special address, "$" for this purpose. +"$" refers to the end of a file. Thus + $p +prints the last line of a file and + 1,$p +prints all of a file. +Here's another file. Print all of it, and +then type the usual w, q, and ready. +Your commands should look like + 1,$p + w + q + ready +#create Ref +1,$p +w +q +#create file +New York Mets Managers + Casey Stengel + Wes Westrum + Gil Hodges + Yogi Berra + Roy McMillan +#copyin +#pipe +ed file +#user +#unpipe +#uncopyin +tail -3 .copy >X1 +#cmp X1 Ref +#log +#next +10.1b 10 +10.2b 5 diff --git a/usr/lib/learn/editor/L10.2b b/usr/lib/learn/editor/L10.2b new file mode 100644 index 0000000000..a3b9102552 --- /dev/null +++ b/usr/lib/learn/editor/L10.2b @@ -0,0 +1,30 @@ +#print +You can of course use "$" with other addresses. +For example, print from the third line of this file +through the end; then leave with the usual w, q, and ready. +#create Ref +IBM +Sperry Rand Univac +Control Data +Honeywell +80 +#create file +Burroughts +National Cash Register +IBM +Sperry Rand Univac +Control Data +Honeywell +#copyout +#pipe +ed file +#user +#unpipe +#uncopyout +tail -5 .ocopy >X1 +#cmp X1 Ref +#log +#next +10.3c 2 +10.2c 5 +10.1b 10 diff --git a/usr/lib/learn/editor/L10.2c b/usr/lib/learn/editor/L10.2c new file mode 100644 index 0000000000..cf308e70a2 --- /dev/null +++ b/usr/lib/learn/editor/L10.2c @@ -0,0 +1,18 @@ +#print +And you can also use other kinds of +addresses with the "$" address. +For example, you can use ".", or +combinations with ".", as addresses. +Consider printing from the current +line to the end of the file - what +would the "p" command look like? +Type "answer COMMAND" where "COMMAND" +is that command. +#copyin +#user +#uncopyin +#match .,$p +#log +#next +10.1b 3 +10.3a 0 diff --git a/usr/lib/learn/editor/L10.3a b/usr/lib/learn/editor/L10.3a new file mode 100644 index 0000000000..24475fce22 --- /dev/null +++ b/usr/lib/learn/editor/L10.3a @@ -0,0 +1,27 @@ +#print +Often you want to refer to the last line +of the file. You don't have to know the number +of lines in the file to do that; there +is a special address, "$", that always +refers to the last line. So you +can print the last line of a file with $p; +try that, then type w, q and ready as usual. +#create Ref +This is the end of the file and the line you should print. +95 +#create file + don't print this line + or this one +This is the end of the file and the line you should print. +#copyout +#pipe +ed file +#user +#unpipe +#uncopyout +tail -2 .ocopy >X1 +#cmp X1 Ref +#log +#next +10.3b 5 +10.3c 10 diff --git a/usr/lib/learn/editor/L10.3b b/usr/lib/learn/editor/L10.3b new file mode 100644 index 0000000000..2e1e174500 --- /dev/null +++ b/usr/lib/learn/editor/L10.3b @@ -0,0 +1,36 @@ +#print +You can print an entire file making use +of the fact that "$" refers to the last line. +The command + 1,$p +prints from the first line to the last one, +or the whole file. Try printing this +whole file with this command, and +then typing w, q and ready. Your commands +should look like + 1,$p + w + q + ready +#create Ref +1,$p +w +q +#create file +New York Mets Managers + Casey Stengel + Wes Westrum + Gil Hodges + Yogi Berra + Roy McMillan +#copyin +#pipe +ed file +#user +#unpipe +#uncopyin +tail -3 .copy >X1 +#cmp X1 Ref +#log +#next +10.2b 10 diff --git a/usr/lib/learn/editor/L10.3c b/usr/lib/learn/editor/L10.3c new file mode 100644 index 0000000000..9190d5451a --- /dev/null +++ b/usr/lib/learn/editor/L10.3c @@ -0,0 +1,19 @@ +#print +Don't forget the use of arithmetic combinations +with the "p" command. For example, the +current line is "." and the next line is ".+1"; +do you see how to print the current line and the +next line with one command? Think of it as "print +from this line to the next line". Type "answer COMMAND" +where COMMAND is what your line with "p" will look like. +#copyin +#user +#uncopyin +#match .,.+1p +#match .,+p +#match .,+1p +#match .,.1p +#log +#next +10.3d 5 +10.1b 10 diff --git a/usr/lib/learn/editor/L10.3d b/usr/lib/learn/editor/L10.3d new file mode 100644 index 0000000000..f0e458f2b8 --- /dev/null +++ b/usr/lib/learn/editor/L10.3d @@ -0,0 +1,13 @@ +#print +Suppose you wanted to print from the current +line to the end of the file? What's the command +for that? Again, type "answer COMMAND" where +COMMAND is what your line with "p" will look like. +#copyin +#user +#uncopyin +#match .,$p +#log +#next +10.3e 5 +10.1b 10 diff --git a/usr/lib/learn/editor/L10.3e b/usr/lib/learn/editor/L10.3e new file mode 100644 index 0000000000..40cb845e50 --- /dev/null +++ b/usr/lib/learn/editor/L10.3e @@ -0,0 +1,14 @@ +#print +Again, remember the possibility of arithmetic +combinations. If "$" is the last line, what +is the line before the last line? Type "answer XXX" +where "XXX" is the way you would refer to the line +before the last line of the file. +#copyin +#user +#uncopyin +#match $-1 +#match $- +#log +#next +10.3f 10 diff --git a/usr/lib/learn/editor/L10.3f b/usr/lib/learn/editor/L10.3f new file mode 100644 index 0000000000..28526fae92 --- /dev/null +++ b/usr/lib/learn/editor/L10.3f @@ -0,0 +1,32 @@ +#print +How would you print from the first line of a file to +the next to last line (thus printing all but the last +line of something)? I'll put you in the editor - do that +and then type the usual w, q and ready. +#create Ref +Boroughs + Manhattan + Brooklyn + Queens + the Bronx + Staten Island +92 +#create file +Boroughs + Manhattan + Brooklyn + Queens + the Bronx + Staten Island +Don't print this line! +#copyout +#pipe +ed file +#user +#unpipe +#uncopyout +tail -7 .ocopy >X1 +#cmp X1 Ref +#log +#next +10.1b 5 diff --git a/usr/lib/learn/editor/L11.1a b/usr/lib/learn/editor/L11.1a new file mode 100644 index 0000000000..37b68b177d --- /dev/null +++ b/usr/lib/learn/editor/L11.1a @@ -0,0 +1,44 @@ +#print +By now you are probably wondering how you +get into the editor if someone else doesn't put +you there. The main command interpreter (the shell) +recognizes + ed +as the name of the editor. (On some systems, it's +also called "e", which is a useful abbreviation.) +You can give a file name, +which becomes the current file. Thus + ed NAME +in response to $ puts you in the editor with +current file as specified by NAME. +So you can print a file with the sequence + ed file + 1,$p + w + q +All right. There is a file in the current +directory named for a New Jersey city. Print +it with "cat" and then with the editor. +Then type "ready". +#create Ref +2 cups sifted all-purpose flour +1 tablespoon double-acting baking powder +1/2 teaspoon salt +1/4 cup butter +3/4 cup milk +119 +#create trenton +2 cups sifted all-purpose flour +1 tablespoon double-acting baking powder +1/2 teaspoon salt +1/4 cup butter +3/4 cup milk +#copyout +#user +#uncopyout +tail -6 .ocopy >X1 +#cmp X1 Ref +#log +#next +12.1a 10 +12.2a 5 diff --git a/usr/lib/learn/editor/L11.2a b/usr/lib/learn/editor/L11.2a new file mode 100644 index 0000000000..d1c77ba955 --- /dev/null +++ b/usr/lib/learn/editor/L11.2a @@ -0,0 +1,48 @@ +#print +So far I have always put you into the editor. +How do you get there yourself? The main command +interpreter (the shell) recognizes + ed +as the name of the editor. (On some systems, +it is also called "e", which is a useful abbreviation.) +You can also say + ed file1 +which put you in the editor with the current file +"file1". So, for example, you can print the +last line of a file with + ed NAME + $p + w + q +where NAME is the name of the file. + +In this directory is a file named "file45". Print the +last line of it, and then exit as above. +#create Ref +This file contains nothing +of great importance and +you should not be printing +these lines because the only +line that you were asked for +was +this line, the last line. +#create file45 +This file contains nothing +of great importance and +you should not be printing +these lines because the only +line that you were asked for +was +this line, the last line. +#copyout +#pipe +#user +#unpipe +#uncopyout +grep last .ocopy >X1 +tail -1 Ref >X2 +#cmp X1 X2 +#log +#next +11.2b 10 +12.2a 5 diff --git a/usr/lib/learn/editor/L11.2b b/usr/lib/learn/editor/L11.2b new file mode 100644 index 0000000000..c9d71b9d67 --- /dev/null +++ b/usr/lib/learn/editor/L11.2b @@ -0,0 +1,28 @@ +#print +You can clearly print a whole file +with + e filename + 1,$p + w + q +which prints a file, just as "cat filename" +does. Print the file "stuff" using the +editor. +Then type "ready". +#create Ref +Actually this file is a very +short file and prints quickly. +60 +#create stuff +Actually this file is a very +short file and prints quickly. +#copyout +#pipe +#user +#unpipe +#uncopyout +tail -3 .ocopy >X2 +#cmp X2 Ref +#log +#next +11.2c 10 diff --git a/usr/lib/learn/editor/L11.2c b/usr/lib/learn/editor/L11.2c new file mode 100644 index 0000000000..9465ec4811 --- /dev/null +++ b/usr/lib/learn/editor/L11.2c @@ -0,0 +1,30 @@ +#print +You can of course execute other shell commands +before going into the editor. For example, +in this directory there is a file named for a New Jersey +city. Find out what file it is; then print it with "cat" +and with the editor to check the listings are the same. +Then type "ready". +#create Ref +2 cups sifted all-purpose flour +1 tablespoon double-acting baking powder +1/2 teaspoon salt +1/4 cup butter +3/4 cup milk +#create trenton +2 cups sifted all-purpose flour +1 tablespoon double-acting baking powder +1/2 teaspoon salt +1/4 cup butter +3/4 cup milk +#copyout +#pipe +#user +#unpipe +#uncopyout +grep '....' .ocopy | tail -5 >X1 +#cmp X1 Ref +#log +#next +12.1a 10 +12.2a 5 diff --git a/usr/lib/learn/editor/L12.1a b/usr/lib/learn/editor/L12.1a new file mode 100644 index 0000000000..3d3668c700 --- /dev/null +++ b/usr/lib/learn/editor/L12.1a @@ -0,0 +1,33 @@ +#print +Each 'w' command typed so far has written the edited material +back on the same file that it came from originally. +This can be changed by giving a filename on the 'w' command: + w camden +will write the current editor buffer +on file 'camden'. What does the following +sequence of commands do? + ed old + w new + q +As you can see, it picks up file 'old', and +writes it on file 'new'. It has the same effect +as + cp old new +does. + +This directory contains a file +with a name beginning with 'h'. Make a copy +of that file named 'norman'. Check the copy +by listing the old and new files with 'cat' before +you type 'ready'. +#create harry +Four score and seven years ago our +fathers brought forth on this continent +a new nation, conceived in liberty and +dedicated to the proposition that +all men are created equal. +#user +#cmp harry norman +#log +#next +12.1b 10 diff --git a/usr/lib/learn/editor/L12.1b b/usr/lib/learn/editor/L12.1b new file mode 100644 index 0000000000..9fe99fd919 --- /dev/null +++ b/usr/lib/learn/editor/L12.1b @@ -0,0 +1,27 @@ +#print +This directory still has both files named 'harry' +and 'norman' in it. You checked that they were +the same with 'cat'. Now, for an easier time, +try 'diff'. If it doesn't report any differences, +you can be sure the files are the same. +#create harry +Four score and seven years ago our +fathers brought forth on this continent +a new nation, conceived in liberty and +dedicated to the proposition that +all men are created equal. +#create norman +Four score and seven years ago our +fathers brought forth on this continent +a new nation, conceived in liberty and +dedicated to the proposition that +all men are created equal. +Type "ready" when you're done experimenting. +#copyin +#user +#uncopyin +grep diff .copy >/dev/null +#log +#next +13.1a 10 +13.2a 5 diff --git a/usr/lib/learn/editor/L12.2a b/usr/lib/learn/editor/L12.2a new file mode 100644 index 0000000000..2395ea727b --- /dev/null +++ b/usr/lib/learn/editor/L12.2a @@ -0,0 +1,39 @@ +#print +Each 'w' command typed so far has written the edited material +back on the same file that it came from originally. +This can be changed by giving a filename on the 'w' command: + w camden +will write the current editor buffer +on file 'camden'. What does the following +sequence of commands do? + ed old + w new + q +As you can see, it picks up file 'old', and +writes it on file 'new'. It has the same effect +as + cp old new +does. + +In this directory there is a file named "old". +Copy that file to file "new" with the editor, using +the commands given above. Check by printing +both files with "cat" that they are the same. +Type "ready" when done. +#create Ref +Four score and seven years ago our +fathers brought forth on this continent +a new nation, conceived in liberty and +dedicated to the proposition that +all men are created equal. +#create old +Four score and seven years ago our +fathers brought forth on this continent +a new nation, conceived in liberty and +dedicated to the proposition that +all men are created equal. +#user +#cmp old new +#log +#next +12.2b 5 diff --git a/usr/lib/learn/editor/L12.2b b/usr/lib/learn/editor/L12.2b new file mode 100644 index 0000000000..bedd0431d9 --- /dev/null +++ b/usr/lib/learn/editor/L12.2b @@ -0,0 +1,17 @@ +#print +Now use the editor to copy file "first" +to file "second". +Then type "ready". +#create Ref +Bell Telephone Laboratories + 600 Mountain Avenue + Murray Hill, New Jersey 07974 +#create first +Bell Telephone Laboratories + 600 Mountain Avenue + Murray Hill, New Jersey 07974 +#user +#cmp Ref second +#log +#next +12.2c 5 diff --git a/usr/lib/learn/editor/L12.2c b/usr/lib/learn/editor/L12.2c new file mode 100644 index 0000000000..c6801448bf --- /dev/null +++ b/usr/lib/learn/editor/L12.2c @@ -0,0 +1,22 @@ +#print +Again, you can type various commands before +entering the editor. This directory +contains a file whose name begins with the +letter 'h'. Make a copy of that file +named "norman". Check by printing +the files, either in the editor or with +the "cat" command, that they are the same. +Then type "ready". +#create harry +Pushkin +Tolstoy +Dostoevsky +Chekhov +Gorky +Pasternak +Solzhenitsyn +#user +#cmp harry norman +#log +#next +12.1b 10 diff --git a/usr/lib/learn/editor/L13.1a b/usr/lib/learn/editor/L13.1a new file mode 100644 index 0000000000..6a2f4ef494 --- /dev/null +++ b/usr/lib/learn/editor/L13.1a @@ -0,0 +1,32 @@ +#print +Remember we said that you didn't have to know the +number of the last line, because '$' could +always be used for that. What if you want to know +how long the file is? Well, the editor command + $= +will tell you what '$' is set to, i.e. the number of +lines in the file. You can find the number of lines in +any file, then, by editing it and then typing "$=". +(You then must leave the editor with the usual w,q). +How many lines are there in file 'henry'? You may want to check +by listing the file with "cat" as well as by using "$=" +in the editor. Don't forget to leave the editor with +the usual 'w', 'q'; eventually, type "answer N" +where N is the number of lines. +#create henry +Murray Hill +Holmdel +Whippany +Madison +Piscataway +Chester +Warren +#copyin +#pipe +#user +#unpipe +#uncopyin +#match 7 +#log +#next +14.1a 10 diff --git a/usr/lib/learn/editor/L13.2a b/usr/lib/learn/editor/L13.2a new file mode 100644 index 0000000000..a377edd25e --- /dev/null +++ b/usr/lib/learn/editor/L13.2a @@ -0,0 +1,34 @@ +#print +Remember that "$" is the last line in +the current file. Suppose you want to +know how long the file is, i.e. what the +number of the last line is. The command + $= +will tell you that. So you can find the +length of the file "data" by saying + ed data + $= + w + q +Try that; then check by listing the file +with "cat" to see how long it is. Then type +"ready". +#create data +This is the file +which you should +find the number +of lines in by +typing "$=" in +the editor and see +that it has exactly +nine lines in it +when printed. +#copyout +#pipe +#user +#unpipe +#uncopyout +grep 9 .ocopy >/dev/null +#log +#next +13.2b 5 diff --git a/usr/lib/learn/editor/L13.2b b/usr/lib/learn/editor/L13.2b new file mode 100644 index 0000000000..d4ffbdd473 --- /dev/null +++ b/usr/lib/learn/editor/L13.2b @@ -0,0 +1,23 @@ +#print +How many lines are there in file "henry"? +When you find out, leave the editor, and +then type "answer N" where N is the number +of lines in file "henry". +#create henry +Murray Hill +Holmdel +Whippany +Madison +Piscataway +Chester +Warren +#copyin +#pipe +#user +#unpipe +#uncopyin +#match 7 +#log +#next +14.1a 10 +14.2a 5 diff --git a/usr/lib/learn/editor/L14.1a b/usr/lib/learn/editor/L14.1a new file mode 100644 index 0000000000..9e7b57d220 --- /dev/null +++ b/usr/lib/learn/editor/L14.1a @@ -0,0 +1,30 @@ +#print +You can also use the "=" command to find out what +the 'current' line is. Since the +current line is referred to as '.', do you see that + .= +is the appropriate command to print the current line +number? So if you go through a sequence like + 3p + .= +the second command will print '3'. That's not very +exciting, so why don't you edit file 'roger', +print the next to last line, and then use '.=' +to find out what it is. Don't forget to exit +from the editor with w, and then q. Then +finish by typing "answer N" where +N is what you found, as usual. +#create roger +this is a short +file containing five lines +of which +this line is next to last +indeed +#copyin +#user +#uncopyin +#match 4 +#log +#next +15.1a 10 +15.2a 5 diff --git a/usr/lib/learn/editor/L14.2a b/usr/lib/learn/editor/L14.2a new file mode 100644 index 0000000000..ef8394e743 --- /dev/null +++ b/usr/lib/learn/editor/L14.2a @@ -0,0 +1,26 @@ +#print +You can also use the "=" command to find out what +the 'current' line is. Since the current line +is named '.', the appropriate command is + .= +and so if you say + 3p + .= +the second command will print '3'. Since you should not +believe what I tell you without checking it, edit file +"doubt" and type the two commands above, which first +print line 3 (and incidentally set "." to that line) and +then ask what number "." is. Then type w, q, ready. +#create doubt +you didn't have to print this line +you didn't have to print this line +to err is human, to really foul things up takes a computer +you didn't have to print this line +you didn't have to print this line +#copyout +#user +#uncopyout +grep 3 .ocopy >dev/null +#log +#next +14.2b 5 diff --git a/usr/lib/learn/editor/L14.2b b/usr/lib/learn/editor/L14.2b new file mode 100644 index 0000000000..28b1249ccf --- /dev/null +++ b/usr/lib/learn/editor/L14.2b @@ -0,0 +1,23 @@ +#print +You can use all kinds of addresses with "=" so +that you can find the number of the last line with + $= +for example. There is a file 'monteverdi' in this +directory: find out the number of the next to last line. +Then exit from the editor with w, q and type "answer N" +where N is the number of the next to last line. +#create monteverdi + madrigals + magnificat a 6 voci + mass a 4 voci + motets + l'orfeo + psalms +#copyin +#user +#uncopyin +#match 5 +#log +#next +15.1a 10 +15.2a 5 diff --git a/usr/lib/learn/editor/L15.1a b/usr/lib/learn/editor/L15.1a new file mode 100644 index 0000000000..b70feced46 --- /dev/null +++ b/usr/lib/learn/editor/L15.1a @@ -0,0 +1,35 @@ +#print +So far you only know how to copy and print existing files +in the editor, and not how to get started from scratch. +The 'a' (append) command lets you type in new text. +For example, the sequence + ed file + a + this is a new line of text + . + w + q +will append the line + this is a new line of text +to the editor buffer, and then write it on "file". +(If "file" doesn't already exist, the editor will +warn you, but it's not an error.) +Note that the material being added ends with the +line that just contains a single '.' and that normal +editor commands then resume. Following this pattern, +make a file named "pres" that contains the +line + +franklin delano roosevelt + +and, after you have written it with a 'w' command, +and done your 'q', try saying "cat pres" to check that +you did it right. +Then type "ready". +#create Ref +franklin delano roosevelt +#user +#cmp pres Ref +#log +#next +15.1b 10 diff --git a/usr/lib/learn/editor/L15.1b b/usr/lib/learn/editor/L15.1b new file mode 100644 index 0000000000..7cd6ffe593 --- /dev/null +++ b/usr/lib/learn/editor/L15.1b @@ -0,0 +1,18 @@ +#print +You can of course put several lines between the 'a' and the '.' +to type in lots of text at one time. Here is a set +of lines: type them in and name the file "fruit". +Type "ready" when done. Input is ... +#create Ref +apple +peach +pear +plum +nectarine +orange +#print Ref +#user +#cmp Ref fruit +#log +#next +16.1a 10 diff --git a/usr/lib/learn/editor/L15.2a b/usr/lib/learn/editor/L15.2a new file mode 100644 index 0000000000..bbc058b4a1 --- /dev/null +++ b/usr/lib/learn/editor/L15.2a @@ -0,0 +1,27 @@ +#print +So far you have learned how to +copy and print existing files, and now +you probably want to know how to add new text +to a file. The "a" (append) command lets +you do that. For example, the sequence + ed file + a + A man, a plan, a canal - Panama. + . + w + q +will append the line + A man, a plan, a canal - Panama. +to the editor buffer, and write it on file "file". +(If "file" didn't exist already, the editor will +warn you. It's not an error, just a warning.) +Try that. Then say "cat file" to check what was written, +and then type "ready". +#create Ref +A man, a plan, a canal - Panama. +#user +#cmp file Ref +#log +#next +15.2b 5 +15.3b 2 diff --git a/usr/lib/learn/editor/L15.2b b/usr/lib/learn/editor/L15.2b new file mode 100644 index 0000000000..d8d5c0c5f1 --- /dev/null +++ b/usr/lib/learn/editor/L15.2b @@ -0,0 +1,14 @@ +#print +Now make a file containing the line + +The Hon. Brendan Byrne + +and write it on file "gov". +Then type "ready". +#create Ref +The Hon. Brendan Byrne +#user +#cmp gov Ref +#log +#next +15.1b 10 diff --git a/usr/lib/learn/editor/L15.2c b/usr/lib/learn/editor/L15.2c new file mode 100644 index 0000000000..6f1b013dbc --- /dev/null +++ b/usr/lib/learn/editor/L15.2c @@ -0,0 +1,19 @@ +#print +Note that every set of lines to be appended ends +with the character '.' alone on a line. This is essential +to get back to editor command level. Whenever you have +been appending, and you later type a 'p' or 'w' command +and the editor appears not to respond, check that you +remember to type the '.' to stop appending. This is a very +common error even among experienced users. Suppose you type +in, appending to a file, five lines; what must you type on +the sixth line before typing 'w'? Type "answer X" where X +is that character. +#copyin +#user +#uncopyin +#match . +#log +#next +15.2d 5 +15.3d 2 diff --git a/usr/lib/learn/editor/L15.2d b/usr/lib/learn/editor/L15.2d new file mode 100644 index 0000000000..a8c6f77ca2 --- /dev/null +++ b/usr/lib/learn/editor/L15.2d @@ -0,0 +1,19 @@ +#print +As we mentioned, you can add several lines at once. Here is +a set of lines; go into the editor, append them, write them +on a file named "fruit", and then leave the editor and +type "ready". +#create Ref +apple +peach +pear +plum +nectarine +orange +#print Ref +#user +#cmp Ref fruit +#log +#next +16.1a 10 +15.3e 5 diff --git a/usr/lib/learn/editor/L15.3b b/usr/lib/learn/editor/L15.3b new file mode 100644 index 0000000000..b7f93e4382 --- /dev/null +++ b/usr/lib/learn/editor/L15.3b @@ -0,0 +1,25 @@ +#print +You can put several lines betwen the 'a' and the '.', as +in this example which creates a file named 'opera'. + ed opera + a + abduction from the seraglio - mozart + aida - verdi + alcina - handel + anna bolena - donizetti + . + w + q +Try this as shown. Then type "ready". +(Notice the warning that "opera" doesn't exist +when you start.) +#create Ref +abduction from the seraglio - mozart +aida - verdi +alcina - handel +anna bolena - donizetti +#user +#cmp opera Ref +#log +#next +15.2c 5 diff --git a/usr/lib/learn/editor/L15.3d b/usr/lib/learn/editor/L15.3d new file mode 100644 index 0000000000..49bae05564 --- /dev/null +++ b/usr/lib/learn/editor/L15.3d @@ -0,0 +1,14 @@ +#print +Use the editor to make a file named 'pres' and containing +the single line + +franklin delano roosevelt + +and then type "ready". +#create Ref +franklin delano roosevelt +#user +#cmp pres Ref +#log +#next +15.3e 5 diff --git a/usr/lib/learn/editor/L15.3e b/usr/lib/learn/editor/L15.3e new file mode 100644 index 0000000000..714d78a667 --- /dev/null +++ b/usr/lib/learn/editor/L15.3e @@ -0,0 +1,16 @@ +#print +Remember that after typing the '.' which ends an append +you can type ordinary commands at the editor. Go into +the editor; append the line + +washington, d.c. + +and then print it with the 'p' command. Then write it +on a file named "city" and leave the editor and type "ready". +#create Ref +washington, d.c. +#user +#cmp city Ref +#log +#next +15.3f 5 diff --git a/usr/lib/learn/editor/L15.3f b/usr/lib/learn/editor/L15.3f new file mode 100644 index 0000000000..29020cd2dd --- /dev/null +++ b/usr/lib/learn/editor/L15.3f @@ -0,0 +1,20 @@ +#print +Now make a file named "towns" that contains the lines +summit +chatham +westfield +cranford +madison +and print it out to check you did it right. +Then type "ready". +#create Ref +summit +chatham +westfield +cranford +madison +#user +#cmp towns Ref +#log +#next +16.1a 10 diff --git a/usr/lib/learn/editor/L16.1a b/usr/lib/learn/editor/L16.1a new file mode 100644 index 0000000000..ca51bfca3f --- /dev/null +++ b/usr/lib/learn/editor/L16.1a @@ -0,0 +1,36 @@ +#print +When you are typing after an 'append' command, +the editor is no longer listening for its ordinary +commands. Between 'a' and '.' none of your +usual 'p', 'w', or 'q' commands are recognized. The only +thing that will make the editor wake up is to type '.' +alone on a line. So to type in text, then print it, +you must go through a sequence like + ed file + a + input text + . + 1,$p + w + q +and you must not type the "1,$p" until you have typed +the '.'. Do you understand? Will the sequence + ed junk + a + input line + $= + . + w + q +print the number of the last line typed in? If you don't +know, try it. Then type 'yes' or 'no'. +#copyin +#pipe +#user +#unpipe +#uncopyin +#match no +#log +#next +16.1b 10 +16.2a 5 diff --git a/usr/lib/learn/editor/L16.1b b/usr/lib/learn/editor/L16.1b new file mode 100644 index 0000000000..776bd62b42 --- /dev/null +++ b/usr/lib/learn/editor/L16.1b @@ -0,0 +1,21 @@ +#print +So far you've only appended to empty files. If the file +you are appending to has something in it, you have to +decide where you want the new material to be placed. +You can give a line address with 'a', and the append +command will place the new material after that line. +For example, + 3a + input + . +places 'input' after line 3. What will be the line +number of the input line? Type 'answer N', as usual. +#pipe +#copyin +#user +#uncopyin +#unpipe +#match 4 +#log +#next +16.1c 10 diff --git a/usr/lib/learn/editor/L16.1c b/usr/lib/learn/editor/L16.1c new file mode 100644 index 0000000000..86dfcbe3a6 --- /dev/null +++ b/usr/lib/learn/editor/L16.1c @@ -0,0 +1,39 @@ +#print +The current directory contains a file +named 'hand'. The third line is missing: +add the line + +middle finger + +after line 2 of this file. +Check what you're doing by printing the file +with + 1,$p +before and after the change. +Then rewrite the file with the usual w, q, +and then type "ready". +#create Ref +thumb +index finger +middle finger +ring finger +little finger +#create hand +thumb +index finger +ring finger +little finger +#create rhand +thumb +index finger +ring finger +little finger +#pipe +#user +#unpipe +#cmp hand Ref +#log +#next +17.2a 5 +18.1a 10 +18.2a 7 diff --git a/usr/lib/learn/editor/L16.2a b/usr/lib/learn/editor/L16.2a new file mode 100644 index 0000000000..f5121add08 --- /dev/null +++ b/usr/lib/learn/editor/L16.2a @@ -0,0 +1,41 @@ +#print +So far you have always appended to an empty file, +so that there was no problem about where the appended lines +were placed in the file. If the file you're appending to +already has lines in it, you can say where you want the +new material to be placed by giving a line address with 'a', +and you can check on this by printing the file. +Try the following sequence and note what happens to the new lines +that are added with the "3a" command: + +ed rivers +1,$p +3a +merrimack +connecticut +hudson +. +1,$p +w +q +ready +#create Ref +penobscot +androscoggin +kennebec +merrimack +connecticut +hudson +delaware +susquehanna +#create rivers +penobscot +androscoggin +kennebec +delaware +susquehanna +#user +#cmp rivers Ref +#log +#next +16.2c 5 diff --git a/usr/lib/learn/editor/L16.2c b/usr/lib/learn/editor/L16.2c new file mode 100644 index 0000000000..8a345a229a --- /dev/null +++ b/usr/lib/learn/editor/L16.2c @@ -0,0 +1,14 @@ +#print +You can see that the 'a' command adds lines after the +line addressed. So if you type + 2a +at the editor, what will be the line number of the +first line that you added? Type "answer N" where N is the +number it will have. +#copyin +#user +#uncopyin +#match 3 +#log +#next +16.1c 5 diff --git a/usr/lib/learn/editor/L17.2a b/usr/lib/learn/editor/L17.2a new file mode 100644 index 0000000000..5d6332b9ab --- /dev/null +++ b/usr/lib/learn/editor/L17.2a @@ -0,0 +1,14 @@ +#print +You must always remember what the computer is expecting +from you: shell commands, editor commands, or input +text after an 'append'. Suppose you are +typing append text: what do you type to get +back to where you can type editor commands? Type +"answer X" where "X" is replaced by what you type. +#copyin +#user +#uncopyin +#match . +#log +#next +17.2b 5 diff --git a/usr/lib/learn/editor/L17.2b b/usr/lib/learn/editor/L17.2b new file mode 100644 index 0000000000..78b480fd04 --- /dev/null +++ b/usr/lib/learn/editor/L17.2b @@ -0,0 +1,12 @@ +#print +What do you type to go from +the editor command level to where +you type input text? (The append command). +Type "answer X" where X is what you type. +#copyin +#user +#uncopyin +#match a +#log +#next +17.2c 5 diff --git a/usr/lib/learn/editor/L17.2c b/usr/lib/learn/editor/L17.2c new file mode 100644 index 0000000000..bf0351be6f --- /dev/null +++ b/usr/lib/learn/editor/L17.2c @@ -0,0 +1,12 @@ +#print +What command do you type to go from the +shell to the editor? Type "answer X" where +X is the command name. +#copyin +#user +#uncopyin +#match e +#match ed +#log +#next +17.2d 5 diff --git a/usr/lib/learn/editor/L17.2d b/usr/lib/learn/editor/L17.2d new file mode 100644 index 0000000000..0d38499f53 --- /dev/null +++ b/usr/lib/learn/editor/L17.2d @@ -0,0 +1,12 @@ +#print +And, finally, what is the last line you type +to go to the shell from the editor? Again, respond +"answer X" where X is the command. +#copyin +#user +#uncopyin +#match q +#log +#next +18.1a 10 +18.2a 5 diff --git a/usr/lib/learn/editor/L18.1a b/usr/lib/learn/editor/L18.1a new file mode 100644 index 0000000000..488a804ec1 --- /dev/null +++ b/usr/lib/learn/editor/L18.1a @@ -0,0 +1,40 @@ +#print +Sometimes it is desirable to add text before a +known line, rather than after it. For this purpose +there is an 'i' (insert) command that places the new +material before the specified line. Otherwise, 'i' +is exactly like 'a', so that + 3i +is the same as + 2a +Remember the address of the last line? Just +before the last line of file 'airlines' +insert the line + +twa + +and then rewrite the file with w, q, and type ready. +#create Ref +american +braniff +continental +delta +eastern +national +pan am +twa +united +#create airlines +american +braniff +continental +delta +eastern +national +pan am +united +#user +#cmp airlines Ref +#log +#next +19.1a 10 diff --git a/usr/lib/learn/editor/L18.2a b/usr/lib/learn/editor/L18.2a new file mode 100644 index 0000000000..dafb343cd4 --- /dev/null +++ b/usr/lib/learn/editor/L18.2a @@ -0,0 +1,42 @@ +#print +Once in a while you want to add text just before +a certain line, rather than just after it. For this purpose +there is a command 'i' (insert) which is just like 'a' +except that the new material goes before the addressed line, +instead of after it. For example, + 3i +is the same as + 2a +Try this sequence, which prints the editor buffer before +and after the insertion, to see what happens. + +ed cars +1,$p +3i +lincoln +chevrolet +. +1,$p +w +q +ready +#create Ref +ford +mercury +lincoln +chevrolet +buick +pontiac +oldsmobile +#create cars +ford +mercury +buick +pontiac +oldsmobile +#user +#cmp cars Ref +#log +#next +18.2c 7 +18.3a 3 diff --git a/usr/lib/learn/editor/L18.2c b/usr/lib/learn/editor/L18.2c new file mode 100644 index 0000000000..5a4bc25ffd --- /dev/null +++ b/usr/lib/learn/editor/L18.2c @@ -0,0 +1,15 @@ +#print +Again, remembering that "5i" is the same as "4a" +what command is the same as + .-1a +to the editor? Respond "answer XX" where XX is that +command. +#copyin +#user +#uncopyin +#match i +#match .i +#log +#next +18.2d 2 +18.2e 6 diff --git a/usr/lib/learn/editor/L18.2d b/usr/lib/learn/editor/L18.2d new file mode 100644 index 0000000000..6da3437aee --- /dev/null +++ b/usr/lib/learn/editor/L18.2d @@ -0,0 +1,11 @@ +#print +What command will insert lines before the second line from the +end of the file? Type "answer XXX" where XXX is that command. +#copyin +#user +#uncopyin +#match $-2i +#match $-3a +#log +#next +18.2e 5 diff --git a/usr/lib/learn/editor/L18.2e b/usr/lib/learn/editor/L18.2e new file mode 100644 index 0000000000..fd06297bb0 --- /dev/null +++ b/usr/lib/learn/editor/L18.2e @@ -0,0 +1,33 @@ +#print +Just before the last line of file 'airlines' +in this directory insert the line + +twa + +and then rewrite the file with w, q, and +type "ready". +#create Ref +american +braniff +continental +delta +eastern +national +pan am +twa +united +#create airlines +american +braniff +continental +delta +eastern +national +pan am +united +#user +#cmp airlines Ref +#log +#next +19.1a 10 +19.2a 5 diff --git a/usr/lib/learn/editor/L18.3a b/usr/lib/learn/editor/L18.3a new file mode 100644 index 0000000000..3b6378d6e9 --- /dev/null +++ b/usr/lib/learn/editor/L18.3a @@ -0,0 +1,13 @@ +#print +Since 'i' is the same as 'a' except for the position +of the inserted material, what character must end +every block of lines inserted with the 'i' command? +Type "answer X" where X is that character. +#copyin +#user +#uncopyin +#match . +#log +#next +18.3b 5 +18.2c 10 diff --git a/usr/lib/learn/editor/L18.3b b/usr/lib/learn/editor/L18.3b new file mode 100644 index 0000000000..2656f6de48 --- /dev/null +++ b/usr/lib/learn/editor/L18.3b @@ -0,0 +1,18 @@ +#print +Remembering that 'i' inserts one line before +the 'a' command, so that after + 3a +the first input line is number 4 while after + 3i +the first input line is number 3, what command +using 'i' is the same as the command + 5a +to the editor? Type "answer XX" where XX is that +command. +#copyin +#user +#uncopyin +#match 6i +#log +#next +18.2c 5 diff --git a/usr/lib/learn/editor/L19.1a b/usr/lib/learn/editor/L19.1a new file mode 100644 index 0000000000..7d83c3ba7e --- /dev/null +++ b/usr/lib/learn/editor/L19.1a @@ -0,0 +1,42 @@ +#print +Now that you know how to add lines to a file, +you will want to know how to get rid of them. +The command + 5d +will delete line 5 of a file. The command + .d +will delete the current line. +In the file 'pres' either the 5th or 6th line +is wrong. Print those lines and delete the bad +one; then rewrite the corrected file. +Then type 'ready'. +#create Ref +george washington +john adams +thomas jefferson +james madison +james monroe +john quincy adams +andrew jackson +martin van buren +william henry harrison +john tyler +#create pres +george washington +john adams +thomas jefferson +james madison +james monroe + this is wrong Qwertyuiop +john quincy adams +andrew jackson +martin van buren +william henry harrison +john tyler +#pipe +#user +#unpipe +#cmp pres Ref +#log +#next +19.1b 10 diff --git a/usr/lib/learn/editor/L19.1b b/usr/lib/learn/editor/L19.1b new file mode 100644 index 0000000000..3fd0369da4 --- /dev/null +++ b/usr/lib/learn/editor/L19.1b @@ -0,0 +1,41 @@ +#print +Just as you can print several lines at once by +giving a range of addresses with the 'p' command, +you can delete several lines at once by giving +two addresses. For example, + 2,5d +deletes lines 2, 3, 4 and 5 of the current file. The +command + 1,.-1d +deletes all lines up to but not including the current line. +And + 1,$d +deletes EVERY line. (Use with extreme caution, obviously.) +There is a file named 'counties' in this directory. +Throw away the first five lines of it and rewrite it. +Then type 'ready' as usual. +#create Ref +Morris +Warren +Union +Somerset +Hunterdon +#create counties +Bergen +Passaic +Sussex +Hudson +Essex +Morris +Warren +Union +Somerset +Hunterdon +#pipe +#user +#unpipe +#cmp counties Ref +#log +#next +20.1a 10 +20.2a 5 diff --git a/usr/lib/learn/editor/L19.2a b/usr/lib/learn/editor/L19.2a new file mode 100644 index 0000000000..263d6b086d --- /dev/null +++ b/usr/lib/learn/editor/L19.2a @@ -0,0 +1,42 @@ +#print +To avoid just accumulating lines forever, you need some +way of getting rid of them. The 'd' command (delete) removes +lines you don't want. Since it also removes lines that +you do want if you tell it to, you should be careful +with this command. Deleting one line at a time +is always pretty safe. For example + 5d +will delete line 5 of a file. Try the following +sequence; note that I've used "cat" +for a change. + +cat bmt +ed bmt +5d +w +q +cat bmt +ready +#create Ref +14th st +23rd st +28th st +34th st +times square +49th st +57th st +#create bmt +14th st +23rd st +28th st +34th st +42nd st +times square +49th st +57th st +#user +#cmp bmt Ref +#log +#next +19.3b 3 +19.2c 8 diff --git a/usr/lib/learn/editor/L19.2c b/usr/lib/learn/editor/L19.2c new file mode 100644 index 0000000000..cabcce8863 --- /dev/null +++ b/usr/lib/learn/editor/L19.2c @@ -0,0 +1,34 @@ +#print +In this directory there is a file "pres" in which +either the 5th line or the 6th line does not +belong. Edit the file, print the dubious lines, +delete the bad one, and then rewrite the file. +Then type "ready". +#create Ref +george washington +john adams +thomas jefferson +james madison +james monroe +john quincy adams +andrew jackson +martin van buren +william henry harrison +john tyler +#create pres +george washington +john adams +thomas jefferson +james madison +james monroe + this is wrong Qwertyuiop +john quincy adams +andrew jackson +martin van buren +william henry harrison +john tyler +#user +#cmp pres Ref +#log +#next +19.2d 5 diff --git a/usr/lib/learn/editor/L19.2d b/usr/lib/learn/editor/L19.2d new file mode 100644 index 0000000000..c9207ac60d --- /dev/null +++ b/usr/lib/learn/editor/L19.2d @@ -0,0 +1,36 @@ +#print +You can delete several lines at once by giving a range +of addresses with the 'd' command. For example, the sequence + +ed howto +2,5d +w +q + +will delete lines 2 through 5 of the file "howto" and write +the shorter material on the file "new". Try that. Then say + +cat howto +cat new + +to see the differences; then type "ready". +#create Ref +To use UNIX: +5. dial ext. 4321 +6. type userid in response to login +7. type commands +#create howto +To use UNIX: +1. turn terminal power on +2. check terminal is in "line" mode +3. check duplex switch in "full" position +4. check baud rate at "300" +5. dial ext. 4321 +6. type userid in response to login +7. type commands +#user +#cmp new Ref +#log +#next +19.2e 5 +20.1a 10 diff --git a/usr/lib/learn/editor/L19.2e b/usr/lib/learn/editor/L19.2e new file mode 100644 index 0000000000..3253fcc67e --- /dev/null +++ b/usr/lib/learn/editor/L19.2e @@ -0,0 +1,30 @@ +#print +Now, for comparison, use the "diff" command to +check on the differences between "howto" and "new". +Try typing + +diff howto new + +and then "ready". +#create howto +To use UNIX: +1. turn terminal power on +2. check terminal is in "line" mode +3. check duplex switch in "full" position +4. check baud rate at "300" +5. dial ext. 4321 +6. type userid in response to login +7. type commands +#create new +To use UNIX: +5. dial ext. 4321 +6. type userid in response to login +7. type commands +#copyin +#user +#uncopyin +#match diff howto new +#match diff new howto +#log +#next +19.2f diff --git a/usr/lib/learn/editor/L19.2f b/usr/lib/learn/editor/L19.2f new file mode 100644 index 0000000000..0a2b6c96f0 --- /dev/null +++ b/usr/lib/learn/editor/L19.2f @@ -0,0 +1,27 @@ +#print +There is a file "counties" in this directory. +Try deleting the first five lines of the file. +Then type "ready". +#create Ref +Morris +Warren +Union +Somerset +Hunterdon +#create counties +Bergen +Passaic +Sussex +Hudson +Essex +Morris +Warren +Union +Somerset +Hunterdon +#user +#cmp counties Ref +#log +#next +20.1a 10 +20.2a 5 diff --git a/usr/lib/learn/editor/L19.3b b/usr/lib/learn/editor/L19.3b new file mode 100644 index 0000000000..6b6a676e18 --- /dev/null +++ b/usr/lib/learn/editor/L19.3b @@ -0,0 +1,32 @@ +#print +You can use any other kind of address you want +with 'd'; for example, + .d +will delete the current line. Remember the +name of the last line? Pick up file +"flower" and delete the last line and +rewrite the file. Then type "ready". +#create Ref +aster +chrysanthemum +daffodil +marigold +petunia +rose +tulip +zinnia +#create flower +aster +chrysanthemum +daffodil +marigold +petunia +rose +tulip +zinnia +hummingbird +#user +#cmp flower Ref +#log +#next +19.2c 10 diff --git a/usr/lib/learn/editor/L2.1a b/usr/lib/learn/editor/L2.1a new file mode 100644 index 0000000000..387c70e2c0 --- /dev/null +++ b/usr/lib/learn/editor/L2.1a @@ -0,0 +1,14 @@ +#print +Now to check that you can type, a line will +be typed at you: type it back in, and then type "ready". +Type the line exactly as it is typed at you, including +the colons that bracket it. + +: pack my box with five dozen liquor jugs : +#copyin +#user +#uncopyin +#match : pack my box with five dozen liquor jugs : +#log +#next +3.1a 10 diff --git a/usr/lib/learn/editor/L2.2a b/usr/lib/learn/editor/L2.2a new file mode 100644 index 0000000000..c25bc1037f --- /dev/null +++ b/usr/lib/learn/editor/L2.2a @@ -0,0 +1,11 @@ +#print +As an easier typing test, see if you can just get +the word "management" in correctly. Type it +in response to "$" and then type "ready". +#copyin +#user +#uncopyin +#match management +#log +#next +3.1a 10 diff --git a/usr/lib/learn/editor/L20.1a b/usr/lib/learn/editor/L20.1a new file mode 100644 index 0000000000..d2aa4f43e0 --- /dev/null +++ b/usr/lib/learn/editor/L20.1a @@ -0,0 +1,46 @@ +#print +You can now change a line of a file, using only the +commands already taught, by deleting the old line +and inserting a new one. +This is not a very convenient way to do that, so +there is a command 'c' (change) which combines +those operations. + 5c + input text + here. + . +will delete line 5 and replace it by the lines + +input text +here. + +Note that the text following 'c', just like the text +after 'i' and 'a', must end with a line containing just +one '.' and nothing else. +This directory contains a file named 'short' +with six lines in it. Change the last line to read + +new version of last line + +and rewrite the file; then end with "ready". +#create Ref +This is a short file +which contains exactly +six lines of text +of which you are +to change the last line +new version of last line +#create short +This is a short file +which contains exactly +six lines of text +of which you are +to change the last line +this is the last line. +#pipe +#user +#unpipe +#cmp Ref short +#log +#next +21.1a 10 diff --git a/usr/lib/learn/editor/L20.2a b/usr/lib/learn/editor/L20.2a new file mode 100644 index 0000000000..58ba72f3e6 --- /dev/null +++ b/usr/lib/learn/editor/L20.2a @@ -0,0 +1,30 @@ +#print +You can now change a line of a file by a slow procedure: delete the +old version and insert the new one. For example, you could replace +line 4 of a file with + 4d + 3a + new version of line 4 + . +right? OK, try that. There is a file named "words" in this +directory and line 4 contains a mistyped word. Correct it and +rewrite the file; then type "ready". +#create Ref +bear +begin +belief +believe +belt +bend +#create words +bear +begin +belief +beleive +belt +bend +#user +#cmp words Ref +#log +#next +20.2b 5 diff --git a/usr/lib/learn/editor/L20.2b b/usr/lib/learn/editor/L20.2b new file mode 100644 index 0000000000..0c361b561c --- /dev/null +++ b/usr/lib/learn/editor/L20.2b @@ -0,0 +1,40 @@ +#print +There is an easier way to do that. You can just say + 5c + input text for new version + . +using the 'c' command ('c' stands for 'change') which +will delete the old version of the line and +replace it. Note that the input text after 'c' ends +with a '.' just like the text after the 'a' or 'i' commands. +This directory contains a file named "lineup". Change +the third line to read "neal walk" and print the file +before and after. Use a sequence like this, ending in ready: + +ed lineup +1,$p +3c +neal walk +. +1,$p +w +q +ready + +#create Ref +walt frazier +earl monroe +neal walk +bill bradley +spencer haywood +#create lineup +walt frazier +earl monroe +john gianelli +bill bradley +spencer haywood +#user +#cmp lineup Ref +#log +#next +20.2c 5 diff --git a/usr/lib/learn/editor/L20.2c b/usr/lib/learn/editor/L20.2c new file mode 100644 index 0000000000..35055bf3c5 --- /dev/null +++ b/usr/lib/learn/editor/L20.2c @@ -0,0 +1,58 @@ +#print +You can also change several lines, and you need not replace +lines with the same number of lines. You can put any amount +of text between the 'c' command and the closing '.', and +you can remove any number of lines from the file by specifying +a range of addresses. For example, + + 2,5c + first + second + . +would replace the FOUR lines 2,3,4 and 5 of the file with TWO +new lines containing "first" and "second". You can of course +use more complicated addresses involving $ and . if you wish. +This directory contains a file "oldrr". Delete the last two +lines and replace them by a line reading + +penn central + +and write the new version on a file named "newrr". Then use "diff" +to compare the old and new versions of the file. +Eventually, type "ready". +#create Ref +maine central +bangor and aroostook +boston and maine +grand trunk +vermont central +boston and albany +new haven +delaware and hudson +new york, susquehanna, and western +erie-lackawanna +chessie system +lehigh valley +long island railroad +penn central +#create oldrr +maine central +bangor and aroostook +boston and maine +grand trunk +vermont central +boston and albany +new haven +delaware and hudson +new york, susquehanna, and western +erie-lackawanna +chessie system +lehigh valley +long island railroad +new york central +pennsylvania +#user +#cmp newrr Ref +#log +#next +21.1a 10 diff --git a/usr/lib/learn/editor/L21.1a b/usr/lib/learn/editor/L21.1a new file mode 100644 index 0000000000..d4785d6328 --- /dev/null +++ b/usr/lib/learn/editor/L21.1a @@ -0,0 +1,17 @@ +#print +Remember all the basic commands: 'e', 'a', 'w' and 'q'. +Make a file named 'test' that contains the following lines, exactly +as presented below. Then type "ready". +#create Ref +maine +new hampshire +vermont +massachusetts +rhode island +connecticut +#print Ref +#user +#cmp Ref test +#log +#next +21.1b 5 diff --git a/usr/lib/learn/editor/L21.1b b/usr/lib/learn/editor/L21.1b new file mode 100644 index 0000000000..3f6d5a27e6 --- /dev/null +++ b/usr/lib/learn/editor/L21.1b @@ -0,0 +1,27 @@ +#print +In this directory there is a file 'fix'. It contains +a mistyped line. Print the file; then change that +line and rewrite the file correctly. +Then type "ready". +#create Ref +Bell System Companies include: +American Telephone and Telegraph Company + Long Lines Division +Western Electric Company +Bell Laboratories +Teletype Corporation +Associated Companies +#create fix +Bell System Companies include: +American Telephone and Telegraph Company + Long Lines Division +Western Electric Company +Bell Lxxxxtories +Teletype Corporation +Associated Companies +#user +#cmp Ref fix +#log +#next +21.1c 5 +21.1e 10 diff --git a/usr/lib/learn/editor/L21.1c b/usr/lib/learn/editor/L21.1c new file mode 100644 index 0000000000..0ea6579497 --- /dev/null +++ b/usr/lib/learn/editor/L21.1c @@ -0,0 +1,87 @@ +#print +This directory contains a file "list" which has +a list of words in it. What word is on the last line +of the file? The file is rather long - I'd suggest you +not try to print all of it. Type "answer WORD" where +WORD is the word on the last line of the file. +#create list +aardvark +adapt +addition +alert +allege +alphabet +announce +answer +apple +architect +arrange +avoid +this +is +going +to +be +very +boring +if +you +keep +trying +to +print +the +whole +file +you +should +have +said +$p +and +I +would +suggest +you +hit +delete +now +and +try +that +instead +i +am +very +patient +and +you +are +not +going +to +like +waiting +for +all +of +this +to +go +on +for +ver +... +... +.. +... +year +youth +zebra +#copyin +#user +#uncopyin +#match zebra +#log +#next +21.1d 5 diff --git a/usr/lib/learn/editor/L21.1d b/usr/lib/learn/editor/L21.1d new file mode 100644 index 0000000000..4b7d67340f --- /dev/null +++ b/usr/lib/learn/editor/L21.1d @@ -0,0 +1,446 @@ +#print +How long is file "text"? (That is, +how many lines does it have, or what +is the line number of the last line.) Remember the +"=" command? This file is also too long for you +to print out in full. +Type "answer N" where N is the number of the last +line. +#create text +a +able +about +above +absolutely +accidents +act +add +administered +admiration +adoring +advancing +adventure +advised +after +afternoon +afterward +again +against +agent +alacrity +all +allow +almost +alone +along +alongside +alp-climbers +alpenstock +alpine +alps +already +also +alter +although +am +among +an +and +animal +animals +another +anxiety? +any +apparent +applause +appointed +appreciation +are +argued +armor-bearers +around +arrange +arrived +article +as +ascend +ascending +ascent +aside +asked +assailed +assaulting +assembled +assist +at +attempt +attended +attention +attracted +avalanches +away +awful +back +badly +baffled +barometer +barrier +battered +battle +be +beautiful +because +become +bed +been +before +began +beginning +behind +being +believed +beneficent +better +between +big +bitter +black +blue +book +both +boughs +brass +break +breast +breath +bridge +bringing +broke +broken +brought +burdens +burst +but +by +called +calmly +came +can +cannot +caravan +carpeted +carried +case +catch +caught +caused +cavalcade +ceased +cellar +center +certainly +chair +chance +change +chaplain +cheered +chief +chilly +church +circumstance +citizens +civilization +clear +clearly +climb +climber +clock +closed +clove +coil +cold +column +comfort +command +commanded +commended +concluded +condition +confronted +consequently +considerable +considered +consisted +constantly +consulting +contrived +convinced +cord +could +country +couple +courage +course +cover +covered +cows +crash +crawling +crept +crippling +crossed +crowd +crowded +cruel +crumbly +crutches +custom +cut +danger +dangerous +dark +dead +deaf +dear +decided +decked +declared +deep +deeply +defective +demanded +demoralization +densely +deployed +descending +describe +desert +deserted +despair +despondency +detachment +detail +detailing +did +die +directly +dirt +disappear +disappeared +dismal +disposition +divert +do +doing +done +donkey +doom +down +draped +dressed +drooped +dull +dumb +during +eager +ear +ears +earth +earthquake +easy +eat +edelweiss +either +elephants +eleven +eloquence +embrace +encounter +end +ended +enough +entered +entirely +established +estimate +even +evening +events +ever +every +everybody +examine +exceeded +excellent +except +excess +exclaimed +excursions +executed +exhaustion +expected +expedition +experimenter +explained +explosion +extreme +eye +eyes +face +faces +fact +fagged +failed +fainted +fallen +false +far +fast +fastened +faster +fatal +father +fatigue +fear +feared +fearful +fears +feature +feel +feet +fell +fellow +fetch +feverishly +few +fifteen +filing +find +finer +firmly +first +five +five-pound +fixed +flank +foot +for +forest +forgotten +form +forth +forty-foot +forward +found +four +frantic +free +frequency +fresh +friend +frightened +from +front +frozen +full +furthest +fury +gave +gazing +general +gentle +get +give +glad +glanced +gliding +go +going +gone +good +got +grace +grand +gratifying +great +green +ground +grow +growing +guide +guides +guttered +had +half +half-mile +halt +hampered +hand +hands +happened +harder +hardly +harris +hat +hate +haunts +have +having +he +head +hear +heard +heavens +heavy +held +here +hesitated +high +hill +him +himself +his +hoist +hold +homes +hook +hook-rope +hoping +horns +host +hotel +hotels +hour +hours +how +hurry +huts +huzza +i +ice-ax +ice-axes +idea +if +implement +implements +imposing +impressive +impulse +in +inches +including +indignant +ingratitude +injured +innocent +inquiries? +inquiring +#copyin +#user +#uncopyin +tail -1 .copy >X1 +%s/../lcount X2 +#cmp X1 X2 +#log +#next +21.1e 6 diff --git a/usr/lib/learn/editor/L21.1e b/usr/lib/learn/editor/L21.1e new file mode 100644 index 0000000000..14ab446cee --- /dev/null +++ b/usr/lib/learn/editor/L21.1e @@ -0,0 +1,33 @@ +#print +This directory contains a file "abot" which +has an extra line (one line was typed twice). +Remove the extra line and rewrite the +file; then type "ready". This file is +fairly short. +#create Ref +seven qualities characterize the clod and seven the +wise man: the wise man does not speak before him +that is greater than he in wisdom; he does not +break into his fellow's speech; he is not in a rush to +reply; he asks what is relevant and replies to the +point; he speaks of first things first and of last +things last; of what he has not heard he says "I +have not heard"; and he acknowledges what is true. + and the opposites apply to the clod. +#create abot +seven qualities characterize the clod and seven the +wise man: the wise man does not speak before him +that is greater than he in wisdom; he does not +break into his fellow's speech; he is not in a rush to +break into his fellow's speech; he is not in a rush to +reply; he asks what is relevant and replies to the +point; he speaks of first things first and of last +things last; of what he has not heard he says "I +have not heard"; and he acknowledges what is true. + and the opposites apply to the clod. +#user +#cmp abot Ref +#log +#next +30.1a 10 +30.2a 5 diff --git a/usr/lib/learn/editor/L3.1a b/usr/lib/learn/editor/L3.1a new file mode 100644 index 0000000000..2c8ea3d5d4 --- /dev/null +++ b/usr/lib/learn/editor/L3.1a @@ -0,0 +1,21 @@ +#print +The editor accepts commands one per line, +just like the other programs in UNIX; but its +commands are unique to it. The +only command present in every editing session is the +last one, 'q' (quit) which returns to the normal +command interpreting program. I'm going to put +you in the editor. Type 'q' to leave, +and then type "ready" when you get the '$' from +the normal command handler. +#create junk +You're in the editor. +#pipe +ed - junk +1p +#user +#unpipe +#cmp junk junk +#log +#next +3.1b 5 diff --git a/usr/lib/learn/editor/L3.1b b/usr/lib/learn/editor/L3.1b new file mode 100644 index 0000000000..3b1e9b8009 --- /dev/null +++ b/usr/lib/learn/editor/L3.1b @@ -0,0 +1,37 @@ +#print +A particularly important editor command +is 'w' (write). This writes whatever +you are working on, including everything you +have typed in or changed, into a file, +so that you can work on it again later. +If you try to quit from the editor without +writing out your changes, the editor will complain +(but only once -- a second 'q' will let you out). +Generally it's wisest to leave the editor by typing + +w +q + +rather than just 'q'. I'll put you in the editor; +type those two commands to leave. Then type +"ready". +#create bpres +Washington Adams Jefferson +#create pres +Washington Adams Jefferson +#pipe +ed pres +#user +#unpipe +#cmp pres bpres +#succeed +Note that the editor typed 27. This is the number +of characters it wrote into the file. This +is reassuring - it tells you the write was +successful. The count of characters read +is also typed, which is why you got a '27' +before your responses. +#log +#next +4.1a 10 +4.2a 5 diff --git a/usr/lib/learn/editor/L30.1a b/usr/lib/learn/editor/L30.1a new file mode 100644 index 0000000000..d0427376d5 --- /dev/null +++ b/usr/lib/learn/editor/L30.1a @@ -0,0 +1,27 @@ +#print +Although it is always possible to fix errors by retyping +the entire erroneous line with the 'c' command, it is +usually much faster to make small changes within +a line. The editor allows this with the 's' (substitute) +command. For example, + s/abc/def/ +will change a line previously reading + xxx abc +into one reading + xxx def +by replacing the string 'abc' in the line with the string 'def'. +In this directory is a file 'pres' with one line that says +'harry' where it should say 'george'. Fix it using the +substitute command to change 'harry' into 'george'. You +should use the 'p' command to print the line before and +after, checking that you did it correctly. Then +rewrite the file and type 'ready'. +#create Ref +george washington +#create pres +harry washington +#user +#cmp Ref pres +#log +#next +30.1b 10 diff --git a/usr/lib/learn/editor/L30.1b b/usr/lib/learn/editor/L30.1b new file mode 100644 index 0000000000..65d65c4d6f --- /dev/null +++ b/usr/lib/learn/editor/L30.1b @@ -0,0 +1,27 @@ +#print +As with other commands, you can specify a line +number in front of the 's' command. Thus + 3s/x/a/ +will change the first 'x' to an 'a' on the third line +of the current file. Pick up file 'town' and +change the 'q' on the last line to a 'p'. Then +rewrite the file and type 'ready'. +#create Ref +south orange +maplewood +millburn +short hills +summit +new providence +#create town +south orange +maplewood +millburn +short hills +summit +new qrovidence +#user +#cmp town Ref +#log +#next +31.1a 10 diff --git a/usr/lib/learn/editor/L30.2a b/usr/lib/learn/editor/L30.2a new file mode 100644 index 0000000000..6bccfcb92a --- /dev/null +++ b/usr/lib/learn/editor/L30.2a @@ -0,0 +1,30 @@ +#print +Changing a whole line with the 'c' command is a slow way +to work when you only want to change a few letters. The 's' (substitute) +command changes the letters within a line. For example, the command + s/abc/def/ +will change a line reading + xxxabc +into one reading + xxxdef +by replacing the string 'abc' with 'def'. Try the following sequence which +alters the first line of the file 'test' within this directory: + +ed test +1p +s/months/years/ +1p +w +q +ready +#create Ref +Four score and seven years ago our +fathers brought forth ... +#create test +Four score and seven months ago our +fathers brought forth ... +#user +#cmp test Ref +#log +#next +30.2b 5 diff --git a/usr/lib/learn/editor/L30.2b b/usr/lib/learn/editor/L30.2b new file mode 100644 index 0000000000..bf4edd6a89 --- /dev/null +++ b/usr/lib/learn/editor/L30.2b @@ -0,0 +1,17 @@ +#print +In this directory is a file 'pres' whose first line says +'harry' where it should say 'george'. Fix it using the +substitute command to change 'harry' into 'george'. You should +use the 'p' command to print the line before and after, checking +that the change took place. Then rewrite the file and +type 'ready'. +#create Ref +george washington +#create pres +harry washington +#user +#cmp pres Ref +#log +#next +30.1b 10 +30.2c 5 diff --git a/usr/lib/learn/editor/L30.2c b/usr/lib/learn/editor/L30.2c new file mode 100644 index 0000000000..1a5665031d --- /dev/null +++ b/usr/lib/learn/editor/L30.2c @@ -0,0 +1,34 @@ +#print +As with other commands, you can specify a line number +with the 's' command. Thus + 3s/x/a/ +will change the first 'x' on line 3 to an 'a'. Here is +a file "street" in which the fifth line has an 'r' +where it should have an 'a'. Try +the sequence + +ed street +5s/r/a/ +5p +w +q +ready +#create Ref +first avenue +second avenue +third avenue +lexington avenue +park avenue +madison avenue +#create street +first avenue +second avenue +third avenue +lexington avenue +prrk avenue +madison avenue +#user +#cmp street Ref +#log +#next +30.2d 5 diff --git a/usr/lib/learn/editor/L30.2d b/usr/lib/learn/editor/L30.2d new file mode 100644 index 0000000000..1deb0b784e --- /dev/null +++ b/usr/lib/learn/editor/L30.2d @@ -0,0 +1,18 @@ +#print +In this directory is a file named "airport" +whose second line says "xx" where it should say +"ne". Edit the file, change those letters, and +rewrite the file. Then type "ready". +#create Ref +idlewild +newark +laguardia +#create airport +idlewild +xxwark +laguardia +#user +#cmp airport Ref +#log +#next +30.2e 5 diff --git a/usr/lib/learn/editor/L30.2e b/usr/lib/learn/editor/L30.2e new file mode 100644 index 0000000000..7635883cdd --- /dev/null +++ b/usr/lib/learn/editor/L30.2e @@ -0,0 +1,24 @@ +#print +Now edit the file named "town" and change +the 'q' on the last line to a 'p'. Rewrite the +corrected file and type 'ready'. +#create Ref +south orange +maplewood +millburn +short hills +summit +new providence +#create town +south orange +maplewood +millburn +short hills +summit +new qrovidence +#user +#cmp town Ref +#log +#next +30.2f 5 +31.1a 10 diff --git a/usr/lib/learn/editor/L30.2f b/usr/lib/learn/editor/L30.2f new file mode 100644 index 0000000000..20b2e507d6 --- /dev/null +++ b/usr/lib/learn/editor/L30.2f @@ -0,0 +1,22 @@ +#print +Now there is a file named "equipment" +and on the next to last line is a word +that contains 'nn' where it should have 'mm'. +Fix it and rewrite the file. Then type "ready". +#create Ref +screwdriver +wrench +saw +hammer +pliers +#create equipment +screwdriver +wrench +saw +hanner +pliers +#user +#cmp equipment Ref +#log +#next +30.2g 5 diff --git a/usr/lib/learn/editor/L30.2g b/usr/lib/learn/editor/L30.2g new file mode 100644 index 0000000000..a32db4fc37 --- /dev/null +++ b/usr/lib/learn/editor/L30.2g @@ -0,0 +1,24 @@ +#print +This directory contains a file named "markets" which +has a 'q' on the last line where it should have a 'p'. +Rewrite the corrected version on a new file named +"nmark". Then type "ready". +#create Ref +shop-rite +acme +kings +a&p +finast +pathmark +#create markets +shop-rite +acme +kings +a&p +finast +qathmark +#user +#cmp nmark Ref +#log +#next +30.2h 5 diff --git a/usr/lib/learn/editor/L30.2h b/usr/lib/learn/editor/L30.2h new file mode 100644 index 0000000000..5be2c4c1e1 --- /dev/null +++ b/usr/lib/learn/editor/L30.2h @@ -0,0 +1,27 @@ +#print +The two files you were editing are still around here. +Use "diff" to see what the differences between them are +and check that the correction was made properly. Then +type "ready". +#create markets +shop-rite +acme +kings +a&p +finast +qathmark +#create nmark +shop-rite +acme +kings +a&p +finast +pathmark +#copyin +#user +#uncopyin +#match diff markets nmark +#match diff nmark markets +#log +#next +31.1a 10 diff --git a/usr/lib/learn/editor/L31.1a b/usr/lib/learn/editor/L31.1a new file mode 100644 index 0000000000..10175ca2b5 --- /dev/null +++ b/usr/lib/learn/editor/L31.1a @@ -0,0 +1,38 @@ +#print +I hope you have been checking the effects of your +substitutions by using the 'p' command before and +after the changes. This is so often desired that +you may type the 'p' on the same line, after the 's' +command. Thus + s/ab/cd/p +changes 'ab' to 'cd' and prints the line after the change. +In this directory there is a file named 'tree'. Try changing +the fourth line, which now reads + spruxx +to read + spruce +and then rewrite the file, and type 'ready'. +#create Ref +pine +fir +hemlock +spruce +birch +beech +hickory +maple +#create tree +pine +fir +hemlock +spruxx +birch +beech +hickory +maple +#user +#cmp Ref tree +#log +#next +32.1a 10 +31.2b 5 diff --git a/usr/lib/learn/editor/L31.2b b/usr/lib/learn/editor/L31.2b new file mode 100644 index 0000000000..264802a725 --- /dev/null +++ b/usr/lib/learn/editor/L31.2b @@ -0,0 +1,25 @@ +#print +This directory contains a file "animal" which has +a mistyped line. Print the file, find the line, +fix the error using the 's' command, and then +rewrite the corrected file and type "ready". +#create Ref +cat +dog +raccoon +groundhog +mouse +mole +#create animal +cat +dog +rakkoon +groundhog +mouse +mole +#user +#cmp animal Ref +#log +#next +32.1a 10 +31.2c 5 diff --git a/usr/lib/learn/editor/L31.2c b/usr/lib/learn/editor/L31.2c new file mode 100644 index 0000000000..4afa2dcb3b --- /dev/null +++ b/usr/lib/learn/editor/L31.2c @@ -0,0 +1,32 @@ +#print +In this directory there is a file "checks" +which contains 3 errors. Fix the spelling errors +and rewrite the file. Then type "ready". +#create Ref + The establishment of credit all over the civilized world made it +possible to develop new inventions, enlarge factories, produce more +goods so that more people could earn wages to buy them. Soon even +the supply of paper money would have been too small to take care of +the needs of business, had it not been for a new form of money. This +was the "check-book dollar." + There are now from 25 to 30 billion dollars in paper money +circulating in the United States. But that is only one tenth of +what is needed to do business every year. The other 90 per cent is +in the form of check-book dollars. +#create checks + The establishment of credit all over the civilized world made it +possible to develop new inventions, enlarge factories, produce more +goods so that more people could earn wages to buy them. Soon even +the supply of paper money would have been too smalp to take care of +the needs of businees, had it not been for a new form of money. This +was the "check-book dollar." + There are now from 25 to 30 billion dollars in paper money +circulating in txe United States. But that is only one tenth of +what is needed to do business every year. The other 90 per cent is +in the form of check-book dollars. +#user +#cmp checks Ref +#log +#next +32.1a 10 +32.2a 5 diff --git a/usr/lib/learn/editor/L32.1a b/usr/lib/learn/editor/L32.1a new file mode 100644 index 0000000000..2e69407aba --- /dev/null +++ b/usr/lib/learn/editor/L32.1a @@ -0,0 +1,29 @@ +#print +Just as you can specify files with an abbreviation, +it is also possible, in the 's' command, to +use an abbreviation for the string to be used +for substitution. Unfortunately, the characters +used to indicate an abbreviation are quite +different, and you must learn them separately for the +editor and the file-name interpreter. (Sorry about +that, but that's the way the world is.) + +The symbol for 'any character' is '.'. Thus + s/a./bc/p +looks for an 'a' followed by anything, and changes those +characters into 'bc'. +Thus the line + what now +would become + whbc now +after that command. +What will the word "floating" become after + s/a./or/ +is executed? Type "answer WORD" where WORD is the new version. +#copyin +#user +#uncopyin +#match flooring +#log +#next +32.1b 10 diff --git a/usr/lib/learn/editor/L32.1b b/usr/lib/learn/editor/L32.1b new file mode 100644 index 0000000000..90067e729e --- /dev/null +++ b/usr/lib/learn/editor/L32.1b @@ -0,0 +1,18 @@ +#print +Note that the substitute command changes the first +instance of something that matches. Consider the +line + now is the time for all good men +and the substitute command + s/tim/TIM/ +applied to it. +Which word in the line will be altered by that command? +Type "answer WORD" where WORD is the word that will +be changed. +#copyin +#user +#uncopyin +#match time +#log +#next +32.1c 10 diff --git a/usr/lib/learn/editor/L32.1c b/usr/lib/learn/editor/L32.1c new file mode 100644 index 0000000000..8bf4dc579d --- /dev/null +++ b/usr/lib/learn/editor/L32.1c @@ -0,0 +1,16 @@ +#print +Now, with the line + now is the time for all good men +and the command + s/t../TIM/p +what word will be changed? Again, type +"answer WORD"; remember that "." matches +any character, and the first match is picked. +#copyin +#user +#uncopyin +#match the +#log +#next +33.1a 10 +33.2a 5 diff --git a/usr/lib/learn/editor/L32.2a b/usr/lib/learn/editor/L32.2a new file mode 100644 index 0000000000..73496b8a0b --- /dev/null +++ b/usr/lib/learn/editor/L32.2a @@ -0,0 +1,32 @@ +#print +Just as you can use abbreviations to specify a class of +filenames, you can use abbreviationss in the editor to recognize +strings in the substitute command. Unfortunately, the +characters used in the editor are quite different from the +ones used in the file-name handler to specify patterns. +(Sorry about that, but that's the way the world is.) + +The symbol for 'any character' is '.' and this will +match any single letter or other character in a line. +For example, + s/a./bc/ +looks for an 'a' followed by anything, and changes those +two letters into 'bc'. Try this sequence and note +what happens. + +ed line +p +s/a./bc/p +w +q +ready +#create Ref +me bcd you +#create line +me and you +#user +#cmp line Ref +#log +#next +32.2b 5 +32.2c 10 diff --git a/usr/lib/learn/editor/L32.2b b/usr/lib/learn/editor/L32.2b new file mode 100644 index 0000000000..69d61cfd56 --- /dev/null +++ b/usr/lib/learn/editor/L32.2b @@ -0,0 +1,14 @@ +#print +Or, to take another example, the command + s/h./ar/ +would turn the word "that" into "tart": the '.' matches +the 'a'. What would that command change the +word "what" into? Reply "answer WORD" where WORD +is what the substitute command would produce. +#copyin +#user +#uncopyin +#match wart +#log +#next +32.2c 5 diff --git a/usr/lib/learn/editor/L32.2c b/usr/lib/learn/editor/L32.2c new file mode 100644 index 0000000000..fd9526511b --- /dev/null +++ b/usr/lib/learn/editor/L32.2c @@ -0,0 +1,14 @@ +#print +What will the word "floating" become after +the command + s/a./or/ +is executed? Type "answer WORD" where WORD is the +new version. +#copyin +#user +#uncopyin +#match flooring +#log +#next +32.2d 5 +32.1b 10 diff --git a/usr/lib/learn/editor/L32.2d b/usr/lib/learn/editor/L32.2d new file mode 100644 index 0000000000..f0c25984dd --- /dev/null +++ b/usr/lib/learn/editor/L32.2d @@ -0,0 +1,11 @@ +#print +Is the word "stop" changed by the command + s/to/xx/p +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +32.2e 5 diff --git a/usr/lib/learn/editor/L32.2e b/usr/lib/learn/editor/L32.2e new file mode 100644 index 0000000000..72bb028738 --- /dev/null +++ b/usr/lib/learn/editor/L32.2e @@ -0,0 +1,12 @@ +#print +Is the word "stop" changed by the command + s/tp/xx/p +Type "yes" or "no". +#copyin +#user +#uncopyin +#match no +#log +#next +32.2f 5 +32.1b 10 diff --git a/usr/lib/learn/editor/L32.2f b/usr/lib/learn/editor/L32.2f new file mode 100644 index 0000000000..5182018ccb --- /dev/null +++ b/usr/lib/learn/editor/L32.2f @@ -0,0 +1,11 @@ +#print +Is the word "stop" changed by the command + s/t./xx/p +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +32.2g 5 diff --git a/usr/lib/learn/editor/L32.2g b/usr/lib/learn/editor/L32.2g new file mode 100644 index 0000000000..b31012c1bf --- /dev/null +++ b/usr/lib/learn/editor/L32.2g @@ -0,0 +1,26 @@ +#print +One place where "." is useful is in changing +letters that are hard to type, e.g. the # and @ +characters. For example, the command + s/a.b/xxx/ +will change "a#b" to "xxx". There is a file named +"goof" in this directory whose third line contains +the word + sp#xll +which should be "spell". Change it and rewrite the file; +then type "ready". +#create Ref +whoever typed this +either couldn't type +or couldn't spell +properly. +#create goof +whoever typed this +either couldn't type +or couldn't sp#xll +properly. +#user +#cmp goof Ref +#log +#next +32.1b 5 diff --git a/usr/lib/learn/editor/L33.1a b/usr/lib/learn/editor/L33.1a new file mode 100644 index 0000000000..6b9a32aa77 --- /dev/null +++ b/usr/lib/learn/editor/L33.1a @@ -0,0 +1,20 @@ +#print +When you want to match one of a few specific characters, and not +just any character, the pattern is similar to the pattern used +in filenames. The patterns used with the editor, by +the way, are called "regular expressions". The string + [abc] +matches 'a', 'b' or 'c'. So if the current line +is + now is the time for all good men +and the command is + s/t[ijk]/xx/ +what word is changed? Type "answer WORD" where WORD is the +word changed by that command. +#copyin +#user +#uncopyin +#match time +#log +#next +33.1b 10 diff --git a/usr/lib/learn/editor/L33.1b b/usr/lib/learn/editor/L33.1b new file mode 100644 index 0000000000..83572235b8 --- /dev/null +++ b/usr/lib/learn/editor/L33.1b @@ -0,0 +1,24 @@ +#print +Write the command that will change +either the word "that" or the word "than" +into "this", and then print the result. Type +"answer COMMAND" on a line, where COMMAND is +that string. (That is, COMMAND +will be of the form + s/.../.../p +where you have replaced the ... with the right stuff.) +You can test this out by going into the editor and +typing in a line that contains "that" and "than" +and trying to change it. You should do that until you +are sure you have the command right. +#copyin +#user +#uncopyin +#match s/tha[nt]/this/p +#match s/tha[tn]/this/p +#match s/tha[nt]/this/gp +#match s/tha[tn]/this/gp +#log +#next +34.1a 10 +34.2a 5 diff --git a/usr/lib/learn/editor/L33.2a b/usr/lib/learn/editor/L33.2a new file mode 100644 index 0000000000..ab451ec74b --- /dev/null +++ b/usr/lib/learn/editor/L33.2a @@ -0,0 +1,27 @@ +#print +When you want to match one of a few specific characters, +and not anything, the pattern is similar to that used in +file names. That is, + [abc] +matches the letters 'a', 'b', or 'c', but nothing +else. Try this sequence and note what happens: + +ed lines +1,$p +1s/[123]/9/ +2s/[123]/9/ +1,$p +w +q +ready +#create Ref +599 +948 +#create lines +519 +348 +#user +#cmp lines Ref +#log +#next +33.2b 5 diff --git a/usr/lib/learn/editor/L33.2b b/usr/lib/learn/editor/L33.2b new file mode 100644 index 0000000000..260823553d --- /dev/null +++ b/usr/lib/learn/editor/L33.2b @@ -0,0 +1,26 @@ +#print +You can of course use the [] operators anywhere in +a pattern. Editor patterns, by the way, are called +"regular expressions". For example, suppose you wanted +to change either the word "trick" or the word "track" +to "stop". What command would you need? +Do you see that + + s/tr[ia]ck/stop/p + +will do that? Now figure out what command you would +need to change either "bear" or "beat" into "best" +and print the line after the change. +Type "answer COMMAND" where COMMAND is that line. +#copyin +#user +#uncopyin +#match s/bea[rt]/best/p +#match s/bea[tr]/best/p +#match s/bea[rt]/best/ +You forgot the "p" part. +#match s/bea[tr]/best/ +You forgot the "p" part. +#log +#next +33.2c 5 diff --git a/usr/lib/learn/editor/L33.2c b/usr/lib/learn/editor/L33.2c new file mode 100644 index 0000000000..f0bc9e07d3 --- /dev/null +++ b/usr/lib/learn/editor/L33.2c @@ -0,0 +1,19 @@ +#print +Suppose the current line is + +now is the time for all good men + +and you type the substitute command + +s/t[ijk]/xx/ + +what word is changed? Type "answer WORD" where +WORD is the word changed in the line. +#copyin +#user +#uncopyin +#match time +#log +#next +34.1a 10 +33.1b 5 diff --git a/usr/lib/learn/editor/L34.1a b/usr/lib/learn/editor/L34.1a new file mode 100644 index 0000000000..2fd76d9387 --- /dev/null +++ b/usr/lib/learn/editor/L34.1a @@ -0,0 +1,17 @@ +#print +You can also specify "all characters except ..." +using an expression of the form + [^ab] +which means "anything except an 'a' or 'b' character". +Will + s/ab[^cde]/xyz23/p +change + xbcabfgh +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +34.1b 10 diff --git a/usr/lib/learn/editor/L34.1b b/usr/lib/learn/editor/L34.1b new file mode 100644 index 0000000000..925143febd --- /dev/null +++ b/usr/lib/learn/editor/L34.1b @@ -0,0 +1,19 @@ +#print +Will the command + s/ab[^cde]/xx/p +change the line + abcxyzabfxyz +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#fail +Remember that the s/.../../ command will +keep looking through the line for something +to change, even if the beginning of the +line doesn't match. +#log +#next +35.1a 10 +35.2a 5 diff --git a/usr/lib/learn/editor/L34.2a b/usr/lib/learn/editor/L34.2a new file mode 100644 index 0000000000..b0b7b0236b --- /dev/null +++ b/usr/lib/learn/editor/L34.2a @@ -0,0 +1,15 @@ +#print +You can also specify "all characters except ..." +using an expression of the form + [^ab] +which means "any character except the letters 'a' or 'b'. +This is just like filename patterns again. Does + [^abc] +match the letter 'a'? Answer "yes" or "no". +#copyin +#user +#uncopyin +#match no +#log +#next +34.2b 5 diff --git a/usr/lib/learn/editor/L34.2b b/usr/lib/learn/editor/L34.2b new file mode 100644 index 0000000000..f143e0213a --- /dev/null +++ b/usr/lib/learn/editor/L34.2b @@ -0,0 +1,11 @@ +#print +Does + [^abc] +match the letter 'd'? Answer "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +34.2c 5 diff --git a/usr/lib/learn/editor/L34.2c b/usr/lib/learn/editor/L34.2c new file mode 100644 index 0000000000..e4c6506f81 --- /dev/null +++ b/usr/lib/learn/editor/L34.2c @@ -0,0 +1,9 @@ +#print +Does [abc] match 'a'? Answer "yes" or "no"? +#copyin +#user +#uncopyin +#match yes +#log +#next +34.2d 5 diff --git a/usr/lib/learn/editor/L34.2d b/usr/lib/learn/editor/L34.2d new file mode 100644 index 0000000000..133ddb9e42 --- /dev/null +++ b/usr/lib/learn/editor/L34.2d @@ -0,0 +1,10 @@ +#print +Does [^abc] match the '*' character? +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +34.2e 5 diff --git a/usr/lib/learn/editor/L34.2e b/usr/lib/learn/editor/L34.2e new file mode 100644 index 0000000000..681a3c6ea8 --- /dev/null +++ b/usr/lib/learn/editor/L34.2e @@ -0,0 +1,22 @@ +#print +Suppose you wanted to match all letters and +punctuation marks. You could try + [^ ] +which is "anything but blank". +Try the following commands: + +ed cut +1p +1s/p[^ ]/xxx/p +w +q +ready +#create Ref +stop this comxxxter +#create cut +stop this computer +#user +#cmp cut Ref +#log +#next +34.2f 5 diff --git a/usr/lib/learn/editor/L34.2f b/usr/lib/learn/editor/L34.2f new file mode 100644 index 0000000000..0dfcca39cb --- /dev/null +++ b/usr/lib/learn/editor/L34.2f @@ -0,0 +1,14 @@ +#print +Will + s/ab[^cde]/xyz23/p +change + xbcabfgh +Type "yes" or "no". (Try it out +first in the editor if you don't know.) +#copyin +#user +#uncopyin +#match yes +#log +#next +34.1b 10 diff --git a/usr/lib/learn/editor/L35.1a b/usr/lib/learn/editor/L35.1a new file mode 100644 index 0000000000..6ef8b47e40 --- /dev/null +++ b/usr/lib/learn/editor/L35.1a @@ -0,0 +1,39 @@ +#print +The "*" character is also used in substitute commands, +but it has a different meaning. Here it means +"any number of repetitions of the previous character". +(including zero!). Thus + a* +is any number of 'a' characters, and + [ab]* +is any number of either 'a' or 'b' characters. +So + s/ab*/xy/ +looks for an 'a' followed by any number of 'b' +letters, and will change + abbb cde +into + xy cde +You can use '*' after anything, including for example +blank. Thus + s/a */a/ +removes all the blanks after the letter 'a'. In this +directory there is a file 'text'. On the third line, +remove the blanks after the word 'the'. Then rewrite the +file and type "ready". +#create Ref +This is the file +for experimentation +with the(substitute) +command. +#create text +This is the file +for experimentation +with the (substitute) +command. +#user +#cmp text Ref +#log +#next +36.1a 10 +36.2a 5 diff --git a/usr/lib/learn/editor/L35.2a b/usr/lib/learn/editor/L35.2a new file mode 100644 index 0000000000..474472c4a2 --- /dev/null +++ b/usr/lib/learn/editor/L35.2a @@ -0,0 +1,31 @@ +#print +The '*' character is also used in the editor patterns (the regular +expressions) but it has quite a different meaning from '*' +as used in filenames. In the editor it means "any +number of repetitions of the previous character." Thus + a* +might match "a" or "aa" or "aaa" or "aaaa" and so on. +It might also match nothing, because "any number +of repetitions" includes "zero"! Perhaps it +will be clearer after you do the following example. +Note what happens to the two lines. Type + +ed file +1,2p +1s/xa*/xy/ +2s/xa*/xy/ +1,2p +w +q +ready +#create Ref +abxy +abxycd +#create file +abxaaa +abxcd +#user +#cmp file Ref +#log +#next +35.2b 5 diff --git a/usr/lib/learn/editor/L35.2b b/usr/lib/learn/editor/L35.2b new file mode 100644 index 0000000000..91cc213f88 --- /dev/null +++ b/usr/lib/learn/editor/L35.2b @@ -0,0 +1,23 @@ +#print +Now suppose we wanted to delete the blanks +after the letter "t" in this line: + +here are a lot of blanks + +This line is on file "blank". Try the sequence + +ed blank +1p +s/t */t/p +w +q +ready +#create Ref +here are a lotof blanks +#create blank +here are a lot of blanks +#user +#cmp blank Ref +#log +#next +35.2c 5 diff --git a/usr/lib/learn/editor/L35.2c b/usr/lib/learn/editor/L35.2c new file mode 100644 index 0000000000..cbf4e9d320 --- /dev/null +++ b/usr/lib/learn/editor/L35.2c @@ -0,0 +1,22 @@ +#print +You can use '*' to look for a string of characters +from one of the character classes. Suppose, for example, +we wanted a long string of either 'a' or 'b', followed +by 'x'. Then we could write + + s/[ab]*x/.../ + +In this directory is a file named "table". +It has only one line. On that line, replace all the digits +followed by a comma with the letters "too big". For example, +"123,000" should become "too big,000". +Then rewrite the file and type "readY". +#create Ref +Heathrow too big,159 +#create table +Heathrow 17073,159 +#user +#cmp table Ref +#log +#next +35.2d 5 diff --git a/usr/lib/learn/editor/L35.2d b/usr/lib/learn/editor/L35.2d new file mode 100644 index 0000000000..d92b66952c --- /dev/null +++ b/usr/lib/learn/editor/L35.2d @@ -0,0 +1,25 @@ +#print +A useful operation is to replace a string of several blanks +by exactly one blank. Note that you can't just write + +s/ */ / + +because the " *" willl match any number of blanks +including zero. Thus it will always match at the beginning +of the line, even if there is no blank there. +The normal sequence is + +s/ */ / +which will only substitute for a string +that has at least one blank in it. +Try that command on the line in the file "line". +Then rewrite the file "line" and type "ready". +#create Ref +here is a long space. +#create line +here is a long space. +#user +#cmp line Ref +#log +#next +35.2e 5 diff --git a/usr/lib/learn/editor/L35.2e b/usr/lib/learn/editor/L35.2e new file mode 100644 index 0000000000..cd3a6a0f77 --- /dev/null +++ b/usr/lib/learn/editor/L35.2e @@ -0,0 +1,33 @@ +#print +A very powerful construction is ".*", +which matches any character (remember '.') +repeated any number of times. For example + +s/a.*b/.../ + +replaces anything of the forms + +axyzb, aaaaaab, a1234b, abbbb + +since it requires just an 'a' and a 'b' +at the ends of the string, with +anything at all in between. +Or, to throw away everything +on a line after the word "stop", you could try + +s/stop.*/stop/ + +In this directory is a file "sentence". +Delete everything after +the word "last" on the second line of the file. +#create Ref +This file has a sentence in which +this is the last +#create sentence +This file has a sentence in which +this is the last word which should be left. +#user +#cmp sentence Ref +#next +36.1a 10 +36.2a 5 diff --git a/usr/lib/learn/editor/L36.1a b/usr/lib/learn/editor/L36.1a new file mode 100644 index 0000000000..d0196c6b6c --- /dev/null +++ b/usr/lib/learn/editor/L36.1a @@ -0,0 +1,33 @@ +#print +So far all the special characters in the substitute command +have been used in the left-hand expression, the one that +is looked for in the line as it exists before the change. +None of these characters are meaningful in the right-hand +expression; for example, + s/ab/a./ +turn "ab" into "a." just as if "." were an ordinary letter. +But there is one character that is special on the right +side of a substitution, which is '&'. The ampersand +is replaced by whatever text is being replaced. In + s/the/&m/ +the string "the" is turned into "them" because the '&' is +replaced by "the". +In this directory there is a file 'text'; on the third line, +change the word 'dog' into 'dogs'; then rewrite the file +and say "ready". +#create Ref +cat +mouse +dogs +rat +#create text +cat +mouse +dog +rat +#user +#cmp text Ref +#log +#next +37.1a 10 +37.2a 6 diff --git a/usr/lib/learn/editor/L36.2a b/usr/lib/learn/editor/L36.2a new file mode 100644 index 0000000000..83801f0c75 --- /dev/null +++ b/usr/lib/learn/editor/L36.2a @@ -0,0 +1,21 @@ +#print +So far all the special characters in the substitute +command are used to select the string to be replaced. +There is one character used in the new string to be inserted. +It is '&' which when used on the right hand side of a substitution, +refers to the expression given on the left hand side. +For example, the command + +s/the/&m/ + +changes "the" into "them". Try that on file "text"; +then rewrite the file and type "ready". +#create Ref +we went to see them yesterday. +#create text +we went to see the yesterday. +#user +#cmp text Ref +#log +#next +36.2b 5 diff --git a/usr/lib/learn/editor/L36.2b b/usr/lib/learn/editor/L36.2b new file mode 100644 index 0000000000..a9e29309c2 --- /dev/null +++ b/usr/lib/learn/editor/L36.2b @@ -0,0 +1,18 @@ +#print +Now, in file 'pets', change the word 'dog' on the third line +into 'dogs'. Then rewrite the file and type "ready". +#create Ref +cats +hamsters +dogs +gerbils +#create pets +cats +hamsters +dog +gerbils +#user +#cmp pets Ref +#log +#next +36.2c 5 diff --git a/usr/lib/learn/editor/L36.2c b/usr/lib/learn/editor/L36.2c new file mode 100644 index 0000000000..ac057700f5 --- /dev/null +++ b/usr/lib/learn/editor/L36.2c @@ -0,0 +1,47 @@ +#print +On the right side of a substitute, none of the other +special characters mean anything unusual. Thus, if you wanted to +replace the letter 'a' by an asterisk, for example, the obvious +com and would work: + +s/a/*/p + +Try, in the file "data", replacing the comma on the last line +with a period. Then rewrite the file and type "ready". +#create Ref + Square Roots +1.00 1.00 +2.00 1.42 +3.00 1.73 +4.00 2.00 +You really shouldn't be +printing all of this file - +did you forget that '$' is +the address of the last +line of a file? +Use that instead of printing everything. +5.00 2.23 +6.00 2.45 +7.00 2.65 +8.00 2.83 +#create data + Square Roots +1.00 1.00 +2.00 1.42 +3.00 1.73 +4.00 2.00 +You really shouldn't be +printing all of this file - +did you forget that '$' is +the address of the last +line of a file? +Use that instead of printing everything. +5.00 2.23 +6.00 2.45 +7.00 2.65 +8.00 2,83 +#user +#cmp data Ref +#log +#next +36.2d 5 diff --git a/usr/lib/learn/editor/L36.2d b/usr/lib/learn/editor/L36.2d new file mode 100644 index 0000000000..c236185a31 --- /dev/null +++ b/usr/lib/learn/editor/L36.2d @@ -0,0 +1,21 @@ +#print +On line 4 of the file "attribute" is either the word +"color" or the word "Color". With one command +add an 's' to the end of the word. Check that you did it right; +then rewrite the file and type "ready". +#create Ref +size weight mass +density shade hue +quality age price +lifetime Colors durability +#create attribute +size weight mass +density shade hue +quality age price +lifetime Color durability +#user +#cmp attribute Ref +#log +#next +37.1a 10 +37.2a 6 diff --git a/usr/lib/learn/editor/L37.1a b/usr/lib/learn/editor/L37.1a new file mode 100644 index 0000000000..da094dbde2 --- /dev/null +++ b/usr/lib/learn/editor/L37.1a @@ -0,0 +1,27 @@ +#print +You can use a range of line numbers with the +substitute command to change more than one line at once. +For example, + 1,5s/dog/&s/ +will change "dog" on each of the first five lines of the +file into "dogs". Edit file "text" and change the word +"cat" on every line into "mouse". +Then rewrite the file and type "ready". +#create Ref +domestic mouse +alley mouse +persian mouse +angora mouse +wildmouse +#create text +domestic cat +alley cat +persian cat +angora cat +wildcat +#user +#cmp text Ref +#log +#next +38.1a 10 +38.2a 6 diff --git a/usr/lib/learn/files/L0 b/usr/lib/learn/files/L0 new file mode 100644 index 0000000000..bab7601e70 --- /dev/null +++ b/usr/lib/learn/files/L0 @@ -0,0 +1,2 @@ +#next +0.1a 10 diff --git a/usr/lib/learn/files/L0.1a b/usr/lib/learn/files/L0.1a new file mode 100644 index 0000000000..f13b557902 --- /dev/null +++ b/usr/lib/learn/files/L0.1a @@ -0,0 +1,36 @@ +#print +This course will help you learn about basic file +handling commands. You should first understand +the special characters # and @: + # cancels the previous character typed; + @ cancels the line being typed. +If you make a typing mistake, you can use these characters to +correct it before you finish the line and the computer won't +ever know about it. For example, what will the +computer really receive if you type + +st#he@ +thf#e + +at it? Reply "answer WORD" where WORD is the word +as it will be interpreted. For example, if +you think it will get 'dog', type + +answer dog + +If you think it will receive the word "bark", type + +answer bark + +Don't forget to leave a space between "answer" and the word +and to hit RETURN at the end of the line. +Don't use any quotation marks in your answer. +#copyin +#user +#uncopyin +#match the +#bad answerthe +Leave a space between "answer" and "the". +#log +#next +0.1b 5 diff --git a/usr/lib/learn/files/L0.1b b/usr/lib/learn/files/L0.1b new file mode 100644 index 0000000000..14c0b30eb8 --- /dev/null +++ b/usr/lib/learn/files/L0.1b @@ -0,0 +1,28 @@ +#print +You should also understand a few simple commands. +When UNIX types a "$" at you, you can type a command. +For example, if you type "date" the computer will tell +you the current date and time. If you see "$" and type "who", +UNIX will tell you who is logged on at present. There are +many other commands, too. You must type a RETURN at the +end of each command line. + +Try the "date" command now: find out what +date it is, and after the computer has responded, type "ready". +And don't forget the RETURN! +#copyin +#user +#uncopyin +grep date .copy >/dev/null +#bad day +You were supposed to type "date" (without quotes). +The computer is very intolerant of spelling errors. +Try again. +#bad "date" +Don't type those quote marks. Try again. +#bad time +The time command does not tell you the wall-clock time. +Try date next time. +#log +#next +0.1c 5 diff --git a/usr/lib/learn/files/L0.1c b/usr/lib/learn/files/L0.1c new file mode 100644 index 0000000000..938f51e18a --- /dev/null +++ b/usr/lib/learn/files/L0.1c @@ -0,0 +1,27 @@ +#print +The computer keeps track of information in "files." +A file might contain a letter to a friend, +or a memo (or part of it) that you are typing, +or any number of other things. +You can list the names of your files +by typing the command "ls". +Try "ls" now; then type "ready". +Remember that each command must go on a separate line +and each line must be ended with RETURN. +#create letter +Dear John: + +I'm terribly sorry... +#create memo +This is a memo. +#create memo1 +Another memo. +#copyin +#user +#uncopyin +grep '^ls' .copy >/dev/null +#bad "ls" +Don't type the quotes, please. Try again. +#log +#next +0.1d 10 diff --git a/usr/lib/learn/files/L0.1d b/usr/lib/learn/files/L0.1d new file mode 100644 index 0000000000..a9e48d3191 --- /dev/null +++ b/usr/lib/learn/files/L0.1d @@ -0,0 +1,30 @@ +#print +File names are essentially arbitrary, +although usually one names files sensibly: +the files that make up a memo +might be called "memo1", "memo2", etc. + +The contents of a file are also entirely up to you: +for example, a file named "memo" could contain + + Analysis of Irregular Statistics + John B. Pencilpusher + + Bell Laboratories, Murray Hill, NJ + .... + +To get at the information in a file, +you have to use the file name, +which in this case is "memo". + +Is there a difference between the name of a file +and the contents of a file? +Type "yes" or "no". +#copyin +#user +#uncopyin +#match yes +#log +#next +1.1a 10 +1.2a 5 diff --git a/usr/lib/learn/files/L1.1a b/usr/lib/learn/files/L1.1a new file mode 100644 index 0000000000..26a5d9a199 --- /dev/null +++ b/usr/lib/learn/files/L1.1a @@ -0,0 +1,12 @@ +#print +The "ls" command will list the names of the files +in your directory. Is there a file named "junk" +present? Find out and then type "yes" or "no". +#copyin +#user +#uncopyin +#match no +#log +#next +2.1a 10 +2.2a 5 diff --git a/usr/lib/learn/files/L1.2a b/usr/lib/learn/files/L1.2a new file mode 100644 index 0000000000..93d258f0ee --- /dev/null +++ b/usr/lib/learn/files/L1.2a @@ -0,0 +1,15 @@ +#print +Use the "ls" command to determine if there is a file +named for a state in the current directory. +Find out and type "yes" or "no". +(Don't use the list you got earlier - I've changed things.) +#create texas +dallas, houston, etc. +#copyin +#user +#uncopyin +#match yes +#log +#next +2.1a 10 +2.2a 5 diff --git a/usr/lib/learn/files/L1.2b b/usr/lib/learn/files/L1.2b new file mode 100644 index 0000000000..f801740528 --- /dev/null +++ b/usr/lib/learn/files/L1.2b @@ -0,0 +1,25 @@ +#print +You can use the "ls" command to find out how +many files you have in your directory. +How many files are there in the current +directory now? Make another list - the list of files +that you made before is no longer right because I added +some files to the directory. When you find out +how many files there are in this directory, type +"answer N" where N is the number of files. +#create a1 +file a1 +#create a2 +file a2 +#create X1 +file a1 +#copyin +#user +#uncopyin +ls | %s/../lcount >X1 +tail -1 .copy >X2 +#cmp X1 X2 +#log +#next +2.1a 10 +2.2a 5 diff --git a/usr/lib/learn/files/L10.1a b/usr/lib/learn/files/L10.1a new file mode 100644 index 0000000000..a7eeec79bc --- /dev/null +++ b/usr/lib/learn/files/L10.1a @@ -0,0 +1,21 @@ +#print +When you are done with something, you will want to know +how to get rid of the file it is on. The command +for that is "rm" (remove). For example + rm junk +throws away the file named "junk". Once it +is gone, it is really gone - there is no way +to "undo" a remove command. Hence this command +should be used with caution. +In this directory there is one file named +for a baseball player. Remove it. +Then type "ready". +#create kernighan +#create yastrzemski +#user +test ! -r yastrzemski && test -r kernighan +#log +#next +11.1a 10 +11.2a 5 +11.3a 2 diff --git a/usr/lib/learn/files/L10.2a b/usr/lib/learn/files/L10.2a new file mode 100644 index 0000000000..e76c627aa5 --- /dev/null +++ b/usr/lib/learn/files/L10.2a @@ -0,0 +1,15 @@ +#print +The way to get rid of a file you are finished with +is with the "rm" (remove) command. For example, + rm junk +will get rid of the file named "junk". +In this directory there is a file named "harry" - +remove it. +Then type "ready". +#create harry +#user +test ! -r harry +#log +#next +10.2b 5 +10.3a 2 diff --git a/usr/lib/learn/files/L10.2b b/usr/lib/learn/files/L10.2b new file mode 100644 index 0000000000..08af6c043e --- /dev/null +++ b/usr/lib/learn/files/L10.2b @@ -0,0 +1,18 @@ +#print +You can remove several files at once with the "rm" command. +And you can use the familiar "*" and "?" characters +to abbreviate several file names. BUT BE CAREFUL - +"rm" is irreversible, and it is all too easy to type something +like "rm *" and get rid of all your files. +In this directory are two files named +"part1" and "part2". +Remove both; then type "ready". +#create part1 +#create part2 +#user +test ! -r part1 && test ! -r part2 +#log +#next +11.1a 10 +11.2a 5 +11.3a 2 diff --git a/usr/lib/learn/files/L10.3a b/usr/lib/learn/files/L10.3a new file mode 100644 index 0000000000..b443cad71d --- /dev/null +++ b/usr/lib/learn/files/L10.3a @@ -0,0 +1,15 @@ +#print +When you are done with something, you will want to +get rid of the file containing it. The command for that +is "rm" (remove). For example + rm junk +throws away the file named "junk". Try that - +there's a file named "junk" in this directory, as you can +verify by doing an "ls". Try another "ls" after the "rm junk"; +then type "ready". +#create junk +#user +test ! -r junk +#log +#next +10.3b 2 diff --git a/usr/lib/learn/files/L10.3b b/usr/lib/learn/files/L10.3b new file mode 100644 index 0000000000..516b558e34 --- /dev/null +++ b/usr/lib/learn/files/L10.3b @@ -0,0 +1,12 @@ +#print +Often you will use "ls" with "rm" +to first find the name of a file, and then remove it. +This directory contains one file whose name begins with "g". +Find out what it is and remove it. +Then type "ready". +#create george +#user +test ! -r george +#log +#next +10.3c 2 diff --git a/usr/lib/learn/files/L10.3c b/usr/lib/learn/files/L10.3c new file mode 100644 index 0000000000..6d5c108ce0 --- /dev/null +++ b/usr/lib/learn/files/L10.3c @@ -0,0 +1,15 @@ +#print +You can remove several files at once with the +"rm" command; for example, + rm tom dick harry +will remove the files "tom", "dick", and "harry". +There are two files in this directory named +for birds: get rid of both. +Then type "ready". +#create eagle +#create bluejay +#user +test ! -r eagle && test ! -r bluejay +#log +#next +10.3d 2 diff --git a/usr/lib/learn/files/L10.3d b/usr/lib/learn/files/L10.3d new file mode 100644 index 0000000000..4b68bea357 --- /dev/null +++ b/usr/lib/learn/files/L10.3d @@ -0,0 +1,23 @@ +#print +You can also use "*" and "?" with +the "rm" command. BUT BE VERY CAREFUL +since, for example, "rm *" will throw away +ALL the files in a directory. +In this directory are some files named +chunk1, chunk2, chunk3 and chunk4. +Get rid of them. Then type "ready". +#create X1 +# +ls >X2 +#create chunk1 +#create chunk2 +#create chunk3 +#create chunk4 +#user +ls >X1 +#cmp X1 X2 +#log +#next +11.1a 10 +11.2a 5 +11.3a 2 diff --git a/usr/lib/learn/files/L11.1a b/usr/lib/learn/files/L11.1a new file mode 100644 index 0000000000..47e4e53a7f --- /dev/null +++ b/usr/lib/learn/files/L11.1a @@ -0,0 +1,42 @@ +#print +To create a second copy of a file, the easiest +way is to use the "cp" (copy) command. +If you tell the computer + cp x y +a copy of file "x" is made and named "y". +Note that this is similar to "mv" in that a new +file named "y" appears, but the difference is +that the old file is not removed. +(If there was already a file named "y", though, the +old contents are lost; be careful.) + +In this directory there is a file which has +a five letter name whose first four letters +are "part". +Print it out; it will tell you to copy +it and what to call the copy. +Do that and then type "ready". +#create X1 +#create george +#create part00 +this is not the right file and you shouldn't +have printed it. Use + part? +not + part* +in this example. +#create part3 +This is the file "part3". I hope you +used a command like + ls part? +or + cat part? +to find it. +Make a copy of this file on file "george". +#user +#cmp george part3 +#log +#next +12.1a 10 +12.2a 5 +12.3a 2 diff --git a/usr/lib/learn/files/L11.2a b/usr/lib/learn/files/L11.2a new file mode 100644 index 0000000000..7c397e7746 --- /dev/null +++ b/usr/lib/learn/files/L11.2a @@ -0,0 +1,16 @@ +#print +To make a new copy of a file, the easiest +way is to use the "cp" command. +If you type + cp x y +a copy of file "x" is made and named "y". +This directory contains a file named "george"; +make a copy named "steve". +Then type "ready". +#create george +this is file george +#user +#cmp steve george +#log +#next +11.2b 5 diff --git a/usr/lib/learn/files/L11.2b b/usr/lib/learn/files/L11.2b new file mode 100644 index 0000000000..f4154e9911 --- /dev/null +++ b/usr/lib/learn/files/L11.2b @@ -0,0 +1,26 @@ +#print +Contrast + cp old new +with + mv old new +as commands; both cause "new" to appear, +but "cp" does not remove "old". +Both, by the way, destroy anything +that happened to be around named "new". +There is a file in this directory +whose name ends in "x". Use "ls" +with the "*x" construction to find its name; +then copy it to file "new", and type "ready". +#create new +old new +#create pix +new new +#create xip +nothing +#user +#cmp pix new +#log +#next +12.1a 10 +12.2a 5 +12.3a 2 diff --git a/usr/lib/learn/files/L11.3a b/usr/lib/learn/files/L11.3a new file mode 100644 index 0000000000..e019f83a07 --- /dev/null +++ b/usr/lib/learn/files/L11.3a @@ -0,0 +1,17 @@ +#print +To make a copy of a file, you can use the +"cp" (copy) command. For example + cp old new +will make a copy of file "old", named "new". +This directory contains a file named "old"; +try the "cp" command to make a file named "new". +Print the file to check on the copy. +When done, type "ready". +#create old +The Brooklyn Museum is at 188 Eastern Parkway, +Brooklyn, NY 11238. +#user +#cmp old new +#log +#next +11.3b 2 diff --git a/usr/lib/learn/files/L11.3b b/usr/lib/learn/files/L11.3b new file mode 100644 index 0000000000..9b3b47b481 --- /dev/null +++ b/usr/lib/learn/files/L11.3b @@ -0,0 +1,13 @@ +#print +Now there is a file named "good" +in this directory. Make a copy named "better", +then type ready. +#create good +This file has +three lines +in it. +#user +#cmp good better +#log +#next +11.3c 2 diff --git a/usr/lib/learn/files/L11.3c b/usr/lib/learn/files/L11.3c new file mode 100644 index 0000000000..a76c5515ae --- /dev/null +++ b/usr/lib/learn/files/L11.3c @@ -0,0 +1,22 @@ +#print +This is a little trickier. The directions +for this step are in a file whose +name begins with "p". Print that file; +it will tell you what to do. Then type "ready". +#create delaware +narrowsburg +port jervis +delaware water gap +easton +trenton +philadelphia +#create pub +Make a copy of the file "delaware" which is +named "hudson". +#user +#cmp delaware hudson +#log +#next +12.1a 10 +12.2a 5 +12.3a 2 diff --git a/usr/lib/learn/files/L12.1a b/usr/lib/learn/files/L12.1a new file mode 100644 index 0000000000..5cd4f7c3d5 --- /dev/null +++ b/usr/lib/learn/files/L12.1a @@ -0,0 +1,42 @@ +#print +Another very useful command is the command + diff x y +which compares two files. It will not print +any output if the two files are the same, but +if the files are different it will print +out the lines that are changed in the two files, +indicating the lines from the first file (x) by a leading "<" +and the lines from the second file (y) by a leading ">". +There are two files in this directory named "old" and "new". +Why don't you first print both files, and then +try using "diff" to compare them? Suppose the files +were hundreds of lines long, and you needed to know +the single difference - do you see how valuable "diff" can be? +As evidence that you did at least half of this, +type "answer word" where "word" is the word added to the +second file. +#create new +Four score and seven +years ago our fathers +brought forth on this +continent a new nation, +conceived in liberty +and dedicated to the +proposition that all +men are created equal. +#create old +Four score and seven +years ago our fathers +brought forth on this +continent a new nation, +conceived in liberty +and dedicated the +proposition that all +men are created equal. +#copyin +#user +#uncopyin +#match to +#log +#next +13.1a diff --git a/usr/lib/learn/files/L12.2a b/usr/lib/learn/files/L12.2a new file mode 100644 index 0000000000..79ee4e1905 --- /dev/null +++ b/usr/lib/learn/files/L12.2a @@ -0,0 +1,25 @@ +#print +To compare two files, you can use the command +"diff" (differences); the line + diff xx yy +will compare the files xx and yy and tell you about +any differences between them. If the files are the same, +the command says nothing. Are the files +"tom" and "dick" the same in this directory? +Find out (print them if you feel insecure) +and reply "yes" or "no". +#create dick +This stuff is not only in +file tom but also +in file dick +#create tom +This stuff is not only in +file tom but also +in file dick +#copyin +#user +#uncopyin +#match yes +#log +#next +12.2b 5 diff --git a/usr/lib/learn/files/L12.2b b/usr/lib/learn/files/L12.2b new file mode 100644 index 0000000000..bb462a8348 --- /dev/null +++ b/usr/lib/learn/files/L12.2b @@ -0,0 +1,27 @@ +#print +Now are the files "dick" and "harry" the same? +Again reply "yes" or "no". +If there are differences between files, "diff" prints +the lines that are different, indicating those +from the first file by "<" and those from +the second file by ">". +#create dick +new york +bridgeport +new haven +new london +providence +boston +#create harry +new york +bridgeport +new haven +providence +boston +#copyin +#user +#uncopyin +#match no +#log +#next +12.2c 5 diff --git a/usr/lib/learn/files/L12.2c b/usr/lib/learn/files/L12.2c new file mode 100644 index 0000000000..e3870bd130 --- /dev/null +++ b/usr/lib/learn/files/L12.2c @@ -0,0 +1,29 @@ +#print +This directory contains two files named "old" and "new"; +What word is in one file but not the other? Find +out. Reply "answer WORD" where WORD is that word. +#create new +Four score and seven +years ago our fathers +brought forth on this +continent a new nation, +conceived in liberty +and dedicated to the +proposition that all +men are created equal. +#create old +Four score and seven +years ago our fathers +brought forth on this +continent a new nation, +conceived in liberty +and dedicated the +proposition that all +men are created equal. +#copyin +#user +#uncopyin +#match to +#log +#next +13.1a diff --git a/usr/lib/learn/files/L12.3a b/usr/lib/learn/files/L12.3a new file mode 100644 index 0000000000..4ebd592066 --- /dev/null +++ b/usr/lib/learn/files/L12.3a @@ -0,0 +1,21 @@ +#print +A very useful command is the command + diff x y +which compares the two files x and y and tells +you any differences between the files. If the files +are the same, it says nothing. To test that, +copy file "george" onto file "harry"; +then say + diff george harry +to verify that the files are the same. +#create george +london bridge +is falling down. +#copyin +#user +#uncopyin +#match diff george harry +#match diff harry george +#log +#next +12.3b 2 diff --git a/usr/lib/learn/files/L12.3b b/usr/lib/learn/files/L12.3b new file mode 100644 index 0000000000..536b593b9f --- /dev/null +++ b/usr/lib/learn/files/L12.3b @@ -0,0 +1,18 @@ +#print +Are the files "memo1" and "memo2" the same? +If they are different, "diff" will print the +lines that are not the same. +Reply "yes" or "no". +#create memo1 +A quick brown fox jumps over the lazy dog. +We were away a year ago. +#create memo2 +A quick brown fox jumps over the lazy dog. +We were away a year ago. +#copyin +#user +#uncopyin +#match yes +#log +#next +12.3c 2 diff --git a/usr/lib/learn/files/L12.3c b/usr/lib/learn/files/L12.3c new file mode 100644 index 0000000000..e8afedebe7 --- /dev/null +++ b/usr/lib/learn/files/L12.3c @@ -0,0 +1,22 @@ +#print +Are the files "old" and "new" in this directory the same? +Again, if they are not, "diff" will print out the differences +marking the lines in the first file named by "<" and the +lines in the second file by ">". Check the results of +diff by printing the files. Then type "yes" or "no". +#create new +This file has three +lines of text in +it to read. +and this has one more. +#create old +This file has three +lines of text in +it to read. +#copyin +#user +#uncopyin +#match no +#log +#next +12.2c 5 diff --git a/usr/lib/learn/files/L13.1a b/usr/lib/learn/files/L13.1a new file mode 100644 index 0000000000..2887447aa8 --- /dev/null +++ b/usr/lib/learn/files/L13.1a @@ -0,0 +1,16 @@ +#print +Let's do a quick review of the things covered +in the files course. To begin, how many files +are there in the current directory? Type "answer N", +where N is the number that you found. +#create X1 +#create X2 +#copyin +#user +#uncopyin +ls | %s/../lcount >X1 +tail -1 .copy >X2 +#cmp X1 X2 +#log +#next +13.1b 5 diff --git a/usr/lib/learn/files/L13.1b b/usr/lib/learn/files/L13.1b new file mode 100644 index 0000000000..1161cc9111 --- /dev/null +++ b/usr/lib/learn/files/L13.1b @@ -0,0 +1,19 @@ +#print +There is a file in this directory whose name begins +with 'z'. Do what it tells you to, then type "ready". +#create X1 +#create X2 +#create zip +Rename the file named "mary" to "joe". +#create joe +I am a file +# +rm -f mary +ls >X1 +mv joe mary +#user +ls >X2 +#cmp X1 X2 +#log +#next +13.1c 5 diff --git a/usr/lib/learn/files/L13.1c b/usr/lib/learn/files/L13.1c new file mode 100644 index 0000000000..8a5edf3b20 --- /dev/null +++ b/usr/lib/learn/files/L13.1c @@ -0,0 +1,24 @@ +#print +There are two files in this directory whose names begin with +the letter 'r'. On what line do they differ? +Type "answer N", where N is the line number where they +first are different. +#create ref +This is a very short file +which contains several lines +some one of which will be changed +in the other version, and your +job is to find out which. +#create refnew +This is a very short file +which contains several lines +some one of which will be changed +in the other version, and your +job is to find out which. +#copyin +#user +#uncopyin +#match 3 +#log +#next +13.1d diff --git a/usr/lib/learn/files/L13.1d b/usr/lib/learn/files/L13.1d new file mode 100644 index 0000000000..dd55663dbd --- /dev/null +++ b/usr/lib/learn/files/L13.1d @@ -0,0 +1,17 @@ +#print +There are several files in this directory whose names +begin with "easy". Remove them, then type "ready". +#create X1 +#create X2 +# +ls >X2 +#create easy1 +#create easyer +#create easyrider +#create easyenough +#user +ls >X1 +#cmp X1 X2 +#log +#next +13.1e diff --git a/usr/lib/learn/files/L13.1e b/usr/lib/learn/files/L13.1e new file mode 100644 index 0000000000..03b9b4c321 --- /dev/null +++ b/usr/lib/learn/files/L13.1e @@ -0,0 +1,16 @@ +#print +This one is tougher than the last one. There are +several files in this directory whose names +begin with "hard". Remove them, then type "ready". +#create X1 +#create X2 +# +ls >X2 +cp X1 "hard 1" +cp X1 "hard er" +#user +ls >X1 +#cmp X1 X2 +#log +#next +13.1f diff --git a/usr/lib/learn/files/L13.1f b/usr/lib/learn/files/L13.1f new file mode 100644 index 0000000000..d164bc937f --- /dev/null +++ b/usr/lib/learn/files/L13.1f @@ -0,0 +1,23 @@ +#print +Suppose you have two files named "dick" and "jane", and you +want to interchange them, so that "dick" contains whatever +was originally in "jane", and "jane" contains what was in "dick". +Will this sequence of commands do the job? + +mv dick jane +mv jane dick + +There are two files named "john" and "mary" +in this directory, if you wish to experiment. +When you have decided, type yes or no. +#create john +this is originally file john +#create mary +this is originally file mary +#copyin +#user +#uncopyin +#match no +#log +#next +13.1g diff --git a/usr/lib/learn/files/L13.1g b/usr/lib/learn/files/L13.1g new file mode 100644 index 0000000000..5c348bf332 --- /dev/null +++ b/usr/lib/learn/files/L13.1g @@ -0,0 +1,20 @@ +#print +Suppose that we really do want to interchange the contents +of the files "dick" and "jane". One way to do it is +to move the contents of "dick" into some temporary file, +then move "jane" onto "dick" (which of course clobbers +the old contents of "dick", but we saved them already), +then finally to move the temporary copy of "dick" to +"jane". There are two files named "dick" and "jane" in this +directory. Interchange their contents, then type "ready". +#create Ref +short file for dick +#create dick +short file for dick +#create jane +another file for jane +#create Ref1 +another file for jane +#user +cmp -s jane Ref && cmp -s dick Ref1 +#log diff --git a/usr/lib/learn/files/L2.1a b/usr/lib/learn/files/L2.1a new file mode 100644 index 0000000000..3d6a7a30ec --- /dev/null +++ b/usr/lib/learn/files/L2.1a @@ -0,0 +1,21 @@ +#print +The "mv" command changes the names of files. +For example, "mv bob bill" changes the name +of file "bob" to be "bill". If there was already +a file named "bill", the old version is destroyed. + +There is a file in +the current directory whose name begins with +the letter "g", like "grant" or "grover". +Find out what the file name really is, and +then change that file to have the name "john". +Then type "ready". +#create george +this should become john +#user +test -r john +#log +#next +3.1a 10 +3.2a 5 +3.3a 2 diff --git a/usr/lib/learn/files/L2.2a b/usr/lib/learn/files/L2.2a new file mode 100644 index 0000000000..b522ee08f7 --- /dev/null +++ b/usr/lib/learn/files/L2.2a @@ -0,0 +1,17 @@ +#print +The "mv" command changes the names of files. +For example, "mv thomas james" changes the +name of the file "thomas" to be "james". + +There is a file in the current directory named +"thomas". Change that file to have the +name "james". Then type "ready". +(The "mv" command, by the way, is like many +UNIX commands in that it is silent unless there is an error.) +#create thomas +xx +#user +test -r james +#log +#next +2.2b 5 diff --git a/usr/lib/learn/files/L2.2b b/usr/lib/learn/files/L2.2b new file mode 100644 index 0000000000..e38143cea1 --- /dev/null +++ b/usr/lib/learn/files/L2.2b @@ -0,0 +1,24 @@ +#print +Now your directory contains a file with a name +that starts with "a" (like "adam", "arthur", etc.). +Find it and change its name to "martin". +Then type "ready". +By the way, if there was already a file around +named "martin", the old version is clobbered +by the new one. +#create andrew +stuff +#user +test -r martin +#fail +Do you remember that the "ls" command will +tell you the names of the files in the current +directory? Thus you can use "ls" to tell you +what your file names are; and then you can use +"mv" to change the name of the file +beginning with "a" to "martin". +#log +#next +3.1a 10 +3.2a 5 +3.3a 2 diff --git a/usr/lib/learn/files/L3.1a b/usr/lib/learn/files/L3.1a new file mode 100644 index 0000000000..dfaabeac84 --- /dev/null +++ b/usr/lib/learn/files/L3.1a @@ -0,0 +1,34 @@ +#print +The "cat" command prints the contents of one or more files. +In fact, it is named "cat" as an abbreviation +for "concatenate". To print the files named "dog" +and "mouse" in succession, you could type either + cat dog + cat mouse +or just + cat dog mouse +If you print them with one command, +the contents are printed in sequence with nothing +between them. + +How many lines are there in all the files +whose names begin with "b"? Find out, then type +"answer N" where N is the total number of lines. +#create ben +the file ben has +a total of three +short lines. +#create bernie +this file has +two lines. +#create bruce +only one line here. +#copyin +#user +#uncopyin +#match 6 +#log +#next +4.1a 10 +4.2a 5 +4.3a 2 diff --git a/usr/lib/learn/files/L3.2a b/usr/lib/learn/files/L3.2a new file mode 100644 index 0000000000..593f8cc98e --- /dev/null +++ b/usr/lib/learn/files/L3.2a @@ -0,0 +1,23 @@ +#print +The command "cat" will print files. For example, you +can print the file named "food" by typing "cat food". +Your current directory has a file named "sam" and a +file named "steve". Which is longer? Find out and +type "answer sam" or "answer steve", giving the name +of the longer file. +#create sam +this is the file sam. it contains +only two lines of text. +#create steve +this file is named steve. it is a +file which contains five lines of text. +this is of course a very short file +by any ordinary standards, although +on UNIX most files are rather short. +#copyin +#user +#uncopyin +#match steve +#log +#next +3.2b 5 diff --git a/usr/lib/learn/files/L3.2b b/usr/lib/learn/files/L3.2b new file mode 100644 index 0000000000..e99f3ba4f3 --- /dev/null +++ b/usr/lib/learn/files/L3.2b @@ -0,0 +1,32 @@ +#print +The "cat" command can also print several files +at once. In fact, it is named "cat" as an abbreviation +for "concatenate". To print the files named "dog" +and "mouse" in succession, you could either +type: + cat dog + cat mouse +or just + cat dog mouse +If you print them with one command, +the files are listed in sequence with nothing +between them. + +This directory contains two files +named "chester" and "charley". What is the +longest word in either file? Type "answer WORD" +where WORD is the longest word you find. +#create charley +most of this file is short but at one place +there is a surprisingly long word. +#create chester +and of the but here now stop go +#copyin +#user +#uncopyin +#match surprisingly +#log +#next +4.1a 10 +4.2a 5 +4.3a 2 diff --git a/usr/lib/learn/files/L3.3a b/usr/lib/learn/files/L3.3a new file mode 100644 index 0000000000..1b082b22f9 --- /dev/null +++ b/usr/lib/learn/files/L3.3a @@ -0,0 +1,18 @@ +#print +A file can be printed on your terminal +by using the "cat" command. Just say +"cat file" where "file" is the file name. +For example, there is a file named +"food" in this directory. List it +by saying "cat food"; then type "ready". +#create food + this is the file + named food. +#copyout +#user +#uncopyout +tail -2 .ocopy >X1 +#cmp X1 food +#log +#next +3.3b 2 diff --git a/usr/lib/learn/files/L3.3b b/usr/lib/learn/files/L3.3b new file mode 100644 index 0000000000..525d4d2d90 --- /dev/null +++ b/usr/lib/learn/files/L3.3b @@ -0,0 +1,23 @@ +#print +Of course, you can print any file with "cat". +In particular, it is common to first use +"ls" to find the name of a file and then "cat" +to print it. Note the difference between +"ls", which tells you the name of the files, +and "cat", which tells you the contents. + +One file in the current directory is named for +a President. Print the file, then type "ready". +#create roosevelt + this file is named roosevelt + and contains three lines of + text. +#copyout +#user +#uncopyout +cp .ocopy X2 +tail -3 .ocopy >X1 +#cmp X1 roosevelt +#log +#next +3.2b 2 diff --git a/usr/lib/learn/files/L4.1a b/usr/lib/learn/files/L4.1a new file mode 100644 index 0000000000..cbc3f2db66 --- /dev/null +++ b/usr/lib/learn/files/L4.1a @@ -0,0 +1,17 @@ +#print +The "ls" command may be given with one +or more file names. In that case, +it will tell which which of the files exist. +How many of the files "doug", "dave", and +"dennis" exist in this directory? Find out +and then type "answer N" where N is the number +you found. +#create dennis +#create doug +#copyin +#user +#uncopyin +#match 2 +#log +#next +5.1a 10 diff --git a/usr/lib/learn/files/L4.2a b/usr/lib/learn/files/L4.2a new file mode 100644 index 0000000000..596ff43afa --- /dev/null +++ b/usr/lib/learn/files/L4.2a @@ -0,0 +1,19 @@ +#print +If a file name is given with the "ls" command, +it tells you whether that file exists. +The file name is listed if the file exists; +if it doesn't, a complaint is typed. +For example, + ls george +will type "george" if the file exists, +and "george not found" if it is missing. + +Is there a file named "alexander" in the +current directory? Find out, then type "yes" or "no". +#copyin +#user +#uncopyin +#match no +#log +#next +4.2b 10 diff --git a/usr/lib/learn/files/L4.2b b/usr/lib/learn/files/L4.2b new file mode 100644 index 0000000000..e0e97bcc34 --- /dev/null +++ b/usr/lib/learn/files/L4.2b @@ -0,0 +1,21 @@ +#print +You can inquire about several files at once +with the "ls" command. If you type, for example, + ls fee fi fo fum +you will be told which of the four files "fee", "fi", "fo", +and "fum" exist. In the current directory only one +of the files "grover", "gerald", or "george" exists. +Find out which one; then rename it "grant". +Type "ready" when you are done. +#create gerald +file +#create garbage +garbage it is. +#user +#create X1 +file +# +cmp -s X1 grant && test ! -r gerald +#log +#next +5.1a 10 diff --git a/usr/lib/learn/files/L4.3a b/usr/lib/learn/files/L4.3a new file mode 100644 index 0000000000..fa380b99d4 --- /dev/null +++ b/usr/lib/learn/files/L4.3a @@ -0,0 +1,20 @@ +#print +You can use the "ls" command to ask whether +a single file exists without listing the entire +directory. For example, "ls george" will list +"george" if there is a file with that name, and +complain if there is not one. This directory +contains a file named "arthur" but no file named +"alan". You can verify that by typing the +ordinary "ls" command. Then try typing "ls arthur" +to see what happens, and follow that by "ls alan". +Then type "ready". +#create arthur +xxx +#copyin +#user +#uncopyin +grep 'ls arthur' .copy >/dev/null && grep 'ls alan' .copy >/dev/null +#log +#next +4.3b 0 diff --git a/usr/lib/learn/files/L4.3b b/usr/lib/learn/files/L4.3b new file mode 100644 index 0000000000..3aec872964 --- /dev/null +++ b/usr/lib/learn/files/L4.3b @@ -0,0 +1,20 @@ +#print +With the "ls" command, you can inquire about several +specific files at once. For example, in the previous +case, you could type + +ls arthur alan + +and be told about both files. + +Which one of the files "bruce" and "ben" exists? +Type "answer NAME", where NAME is the one you find. +#create bruce +bruce +#copyin +#user +#uncopyin +#match bruce +#log +#next +4.3c 2 diff --git a/usr/lib/learn/files/L4.3c b/usr/lib/learn/files/L4.3c new file mode 100644 index 0000000000..11b9adedce --- /dev/null +++ b/usr/lib/learn/files/L4.3c @@ -0,0 +1,16 @@ +#print +Your directory contains only one of the following +files: "richard", "robert", "ralph", "roger". Find out +which one exists, and print the contents of that file +on your terminal (remember the "cat" command?). +Then type "ready". +#create robert +this is the contents of file +robert which you had to print. +#copyin +#user +#uncopyin +grep 'cat rob' .copy >/dev/null +#log +#next +5.1a 10 diff --git a/usr/lib/learn/files/L5.1a b/usr/lib/learn/files/L5.1a new file mode 100644 index 0000000000..6e206f480f --- /dev/null +++ b/usr/lib/learn/files/L5.1a @@ -0,0 +1,34 @@ +#print +Most UNIX commands, like "ls" and "cat", let you +specify any number of file names after the command. +To make this as easy as possible, there are some +ways to abbreviate file names. This is usually +faster and more accurate than typing out the list in full. + +For example, when the character "?" is used in a file name, +it will represent any character that might be +in a file name. That is, the name "a?" is +an abbreviation for the files "a1", "a2", "aa", +and so forth. You can say + ls a? +and if there are any file names beginning with +"a" that are exactly two letters long, the computer +will tell you their names. Try that here. +First list all the file names with "ls"; then type + ls a? +to get all the two letter names beginning with "a". +Then type "ready". +#create a1 +#create a12 +#create abcdef +#create ax +#create aa +#copyin +#user +#uncopyin +grep '^ls a?$' .copy >/dev/null +#log +#next +5.1b 0 +5.1c 5 +5.1e 10 diff --git a/usr/lib/learn/files/L5.1b b/usr/lib/learn/files/L5.1b new file mode 100644 index 0000000000..7f4b44c71a --- /dev/null +++ b/usr/lib/learn/files/L5.1b @@ -0,0 +1,20 @@ +#print +Will the name + xyz +be selected by the pattern + x? +in an "ls" command? +Type "yes" or "no". If you +have trouble, there is such a file +in the current directory, +so you can find out by trial and error. +(For example, you might do an ordinary "ls" +and then try "ls x?" and compare the results.) +#create xyz +#copyin +#user +#uncopyin +#match no +#log +#next +5.1c 0 diff --git a/usr/lib/learn/files/L5.1c b/usr/lib/learn/files/L5.1c new file mode 100644 index 0000000000..39b8895042 --- /dev/null +++ b/usr/lib/learn/files/L5.1c @@ -0,0 +1,26 @@ +#print +The "?" may appear anywhere in the name. +For example you can type + a?bc +to match the list of names + axbc, aybc, a3bc +and so forth. +But the number of characters must always agree. +How many of the following file names +are matched by "x?xx"? + x1xx, y1xx, x1xxa, xxx +Type "answer N" where N is the number of matching names. +You can experiment in the current directory to +check your answer before typing it. +#create x1xx +#create x1xxa +#create y1xx +#create xxx +#copyin +#user +#uncopyin +#match 1 +#log +#next +5.1d 0 +5.1e 5 diff --git a/usr/lib/learn/files/L5.1d b/usr/lib/learn/files/L5.1d new file mode 100644 index 0000000000..38ebe8449f --- /dev/null +++ b/usr/lib/learn/files/L5.1d @@ -0,0 +1,14 @@ +#print +Will the name + ?xx +match "axx"? Again, you may +experiment before typing your +answer. +#create axx +#copyin +#user +#uncopyin +#match yes +#log +#next +5.1e 0 diff --git a/usr/lib/learn/files/L5.1e b/usr/lib/learn/files/L5.1e new file mode 100644 index 0000000000..03c4142b9c --- /dev/null +++ b/usr/lib/learn/files/L5.1e @@ -0,0 +1,29 @@ +#print +Not only may the ? appear anywhere in a name, +but there may be several ? characters in it. +For example, + g??rge +will match "george" and "goerge", among others. +And "a??" will match "abc" or "a11" (but NOT "ax"). +Look at the files in the current directory and decide +how many names the pattern + a?b?c +will select. Again, you can try this out +by comparing an ordinary "ls" with "ls a?b?c" +to see what happens. When you figure +out how many names are selected, +type "answer N" where N is the number of file names. +#create a0b0c +#create a0bc +#create a0x0c +#create a1bxc +#create aabbc +#create azbzcz +#copyin +#user +#uncopyin +#match 3 +#log +#next +6.1a 5 +6.2a 2 diff --git a/usr/lib/learn/files/L6.1a b/usr/lib/learn/files/L6.1a new file mode 100644 index 0000000000..0eead33296 --- /dev/null +++ b/usr/lib/learn/files/L6.1a @@ -0,0 +1,33 @@ +#print +Since the "?" character only matches single characters, +it isn't useful for such questions as "how many files +have names beginning with g?" There is another character, + * +which can be used in patterns for file names, and which matches +any number of characters of any sort. Thus + g* +matches anything beginning with g. +And + *x +matches anything ending in x. +There is one file in this directory whose name ends +in "memo". Find out that file name +and print the contents of the file. Then type "ready". +#create mymemo +This is the 7-line file "mymemo"; you should +have typed "ls *memo", which would print +"mymemo", and then typed the +command "cat mymemo". +Or just plain "cat *memo" would have worked. +But whatever you did, you got it right +and now you can type "ready". +#copyout +#user +#uncopyout +tail -7 .ocopy >X2 +#cmp mymemo X2 +#log +#next +6.1b 0 +6.1c 5 +6.1e 10 diff --git a/usr/lib/learn/files/L6.1b b/usr/lib/learn/files/L6.1b new file mode 100644 index 0000000000..f7f0d01ea3 --- /dev/null +++ b/usr/lib/learn/files/L6.1b @@ -0,0 +1,14 @@ +#print +Will the file name "abcd" +be matched by "a*d"? Again, +if you are not sure, you can experiment +in this directory with commands like +"ls" and "ls a*d". +#create abcd +#copyin +#user +#uncopyin +#match yes +#log +#next +6.1c diff --git a/usr/lib/learn/files/L6.1c b/usr/lib/learn/files/L6.1c new file mode 100644 index 0000000000..bf8d88489c --- /dev/null +++ b/usr/lib/learn/files/L6.1c @@ -0,0 +1,13 @@ +#print +There is one file in this directory whose name begins +with "g". Rename it so the "g" at the beginning +of the name is replaced by "h". +Then type ready. +#create g23 +g23, of course +#user +test -r h23 && test ! -r g23 +#log +#next +6.1d 0 +6.1e 5 diff --git a/usr/lib/learn/files/L6.1d b/usr/lib/learn/files/L6.1d new file mode 100644 index 0000000000..dcf8678dc7 --- /dev/null +++ b/usr/lib/learn/files/L6.1d @@ -0,0 +1,16 @@ +#print +What does "*b*" match? Clearly, any file +with a "b" anywhere in its name. Similarly, +how many files in this directory have +"se" somewhere in their name? +Type "answer N" when you figure it out. +#create arise +#create reset +#create set +#copyin +#user +#uncopyin +#match 3 +#log +#next +6.1e diff --git a/usr/lib/learn/files/L6.1e b/usr/lib/learn/files/L6.1e new file mode 100644 index 0000000000..cc640d4625 --- /dev/null +++ b/usr/lib/learn/files/L6.1e @@ -0,0 +1,19 @@ +#print +There is exactly one file name which matches both + ab* +and + a?d +in the current directory. What is it? +Type "answer NAME" where NAME is its name. +#create abc +#create abd +#create add +#copyin +#user +#uncopyin +#match abd +#log +#next +7.1a 10 +7.2a 5 +7.3a 2 diff --git a/usr/lib/learn/files/L6.2a b/usr/lib/learn/files/L6.2a new file mode 100644 index 0000000000..b94e7b54f0 --- /dev/null +++ b/usr/lib/learn/files/L6.2a @@ -0,0 +1,34 @@ +#print +Since the '?' character only matches single +characters in file names, it is not useful for +questions like "how many files have names which +begin with the letter g?" There is another character + * +which can be used in patterns for file names +and matches any number of any kind of characters. +So + g* +selects all file names beginning with g, and + *x +selects all file names which end in x. Try + ls *x +How many files match? +Compare with an ordinary + ls +if you like. Type "answer N" eventually where +N is the number of files whose names end in "x". +#create abcx +#create abcxdef +#create memox +#create memoy +#create memoz +#create x +#create x53x +#copyin +#user +#uncopyin +#match 4 +#log +#next +6.2b 8 +6.1a 1 diff --git a/usr/lib/learn/files/L6.2b b/usr/lib/learn/files/L6.2b new file mode 100644 index 0000000000..faaf442be9 --- /dev/null +++ b/usr/lib/learn/files/L6.2b @@ -0,0 +1,22 @@ +#print +There is one file in this directory whose name ends +in "memo". Find out that file name and print +the contents of the file. Then type "ready". +#create mymemo +This is the 7-line file "mymemo"; you should +have typed "ls *memo", which would print +"mymemo", and then typed the +command "cat mymemo". +Or just plain "cat *memo" would have worked. +But whatever you did, you got it right +and now you can type "ready". +#copyout +#user +#uncopyout +tail -7 .ocopy >X2 +#cmp mymemo X2 +#log +#next +6.1b 0 +6.1c 5 +6.1e 10 diff --git a/usr/lib/learn/files/L7.1a b/usr/lib/learn/files/L7.1a new file mode 100644 index 0000000000..871f82f26d --- /dev/null +++ b/usr/lib/learn/files/L7.1a @@ -0,0 +1,38 @@ +#print +Sometimes ? is too flexible, and you +only want to allow a few characters. For example, +you might want to abbreviate + ls memo.ab memo.ac +without picking up "memo.ad", memo.ae", etc. +You can match one of a set of particular characters by +putting them in brackets "[]" in the list you use with "ls". +For example, + [bc] +matches either b or c but no other letters, +so "ls memo.a[bc]" is the abbreviation for +"ls memo.ab memo.ac". +You can have as many characters as needed between [ and ]. + +Type the "ls" command that recognizes + a1cat + a2cat + a3cat +and no other files. Then type "ready". +#create a1bat +#create a1cat +#create a2cat +#create a3cat +#create a4cat +#create acat +#copyin +#user +#uncopyin +#match ls a[123]cat +#match ls a[1-3]cat +#match ls a1cat a2cat a3cat +You were supposed to use a[123]cat. +Imagine doing it your way with 10 files. +#log +#next +8.1a 10 +8.2a 5 diff --git a/usr/lib/learn/files/L7.2a b/usr/lib/learn/files/L7.2a new file mode 100644 index 0000000000..5f51b4bf6e --- /dev/null +++ b/usr/lib/learn/files/L7.2a @@ -0,0 +1,30 @@ +#print +Sometimes ? is too flexible, and you +only want to allow a few characters. For example, +you might want to abbreviate + ls memo.ab memo.ac +without picking up "memo.ad", "memo.ae", and so forth. +You can match one of a set of particular characters by +putting them in brackets "[]" in the list you use with "ls". +For example, + [bc] +matches either b or c but no other letters. Thus + ls memo.a[bc] +will list exactly "memo.ab" and "memo.ac" if present. + +How many of the files + xya, xyb, xyc, xyd +exist in this directory? +Type "answer N" where N is the number. +#create xyb +#create xyc +#create xye +#create xyf +#create xy1 +#copyin +#user +#uncopyin +#match 2 +#log +#next +7.2b 10 diff --git a/usr/lib/learn/files/L7.2b b/usr/lib/learn/files/L7.2b new file mode 100644 index 0000000000..a86c7f8d28 --- /dev/null +++ b/usr/lib/learn/files/L7.2b @@ -0,0 +1,32 @@ +#print +You can put any number of characters between [..] +characters, as in + [abcdef] +which matches any of the six letters from a to f; +and you can put something like that anywhere in a pattern +for a file name. For example, + ls [abcd]x +matches any of + ax, bx, cx, dx +You can also combine this with other operators such as +* or ?. For example, + ls [ab]? +matches all two-letter names beginning with a or b. +How would you ask for all names, of any length, ending +in 1 2 or 3? +You can experiment in this directory; eventually, +type the "ls" command you decide on followed by "ready". +#create a1 +#create a12 +#create a1a +#create a2 +#create a23 +#create aa1 +#create abc1 +#copyin +#user +#uncopyin +#match ls *[123] +#log +#next +8.1a 10 diff --git a/usr/lib/learn/files/L7.3a b/usr/lib/learn/files/L7.3a new file mode 100644 index 0000000000..f757a518a0 --- /dev/null +++ b/usr/lib/learn/files/L7.3a @@ -0,0 +1,28 @@ +#print +Sometimes ? is too flexible, and you +only want to allow a few characters. For example, +you might want to abbreviate + ls memo.ab memo.ac +without picking up "memo.ad", "!"memo.ae", and so forth. +You can match one of a set of particular characters by +putting them in brackets "[]" in the list you use with "ls". +For example, + [bc] +matches either b or c but no other letters. +Thus the command + ls memo.a[bc] +would match "memo.ab", "memo.ac", and nothing else. +Try that command in this directory: type a plain +"ls" first, and then "ls memo.a[bc]". +How many files does "ls memo.a[bc]" match? +Type "answer N" where N is the number. +#create memo.ab +#create memo.abc +#create memo.bc +#copyin +#user +#uncopyin +#match 1 +#log +#next +7.3b 2 diff --git a/usr/lib/learn/files/L7.3b b/usr/lib/learn/files/L7.3b new file mode 100644 index 0000000000..1d3b1072f5 --- /dev/null +++ b/usr/lib/learn/files/L7.3b @@ -0,0 +1,17 @@ +#print +You can use the [] characters anywhere you want +in a file name. For example, + ls a[bc]d +would match abd or acd, right? +What is the command that finds out how +many files are named "ax" or "bx"? +Type that command, then "ready". +#create ax +#create bx +#copyin +#user +#uncopyin +#match ls [ab]x +#log +#next +7.3c 2 diff --git a/usr/lib/learn/files/L7.3c b/usr/lib/learn/files/L7.3c new file mode 100644 index 0000000000..8b87957631 --- /dev/null +++ b/usr/lib/learn/files/L7.3c @@ -0,0 +1,23 @@ +#print +You can put any number of characters between the +brackets. For example, + ab[123456789] +could match up to 9 names, of the sort + ab1, ab2, ab3, ab4, ab5, ... +How many of the following names exist in this +directory? + p1end, p2end, p3end, p4end, p5end +Check with a ordinary "ls". Type "answer N" when you +know. +#once #create p1end +#once #create p3endx +#once #create p4end +#once #create p6end +#copyin +#user +#uncopyin +#match 2 +#log +#next +8.1a 10 +8.2a 5 diff --git a/usr/lib/learn/files/L8.1a b/usr/lib/learn/files/L8.1a new file mode 100644 index 0000000000..2228490e87 --- /dev/null +++ b/usr/lib/learn/files/L8.1a @@ -0,0 +1,25 @@ +#print +Sometimes you want to request one of a limited +range of characters. This is possible with an +expression like + [a-d] +which matches a, b, c, or d. Thus, to take +some combinations + ab[c-f] +matches + abc, abd, abe, abf +Try typing "ls a[0-9]" +and see how many files it matches. Type that +number in the form "answer N". +#create a0 +#create a1 +#create a5 +#create ax +#copyin +#user +#uncopyin +#match 3 +#log +#next +9.1a 10 +9.2a 4 diff --git a/usr/lib/learn/files/L8.2a b/usr/lib/learn/files/L8.2a new file mode 100644 index 0000000000..6b59b79f2f --- /dev/null +++ b/usr/lib/learn/files/L8.2a @@ -0,0 +1,16 @@ +#print +Will the command + ls georg[a-f] +match the name + george +Type yes or no. +Experiment first if you want. +#create george +#copyin +#user +#uncopyin +#match yes +#log +#next +8.2b 5 +9.1a 10 diff --git a/usr/lib/learn/files/L8.2b b/usr/lib/learn/files/L8.2b new file mode 100644 index 0000000000..8fd3ef86c2 --- /dev/null +++ b/usr/lib/learn/files/L8.2b @@ -0,0 +1,23 @@ +#print +The command + ls [aeiou]*.c +will match all but one of the following names. + e.c + alpha.c + edward + u23.c +Which one? Type "answer NAME" where NAME +is the file that doesn't match. You can experiment +first, as usual. +#create alpha.c +#create e.c +#create edward +#create u23.c +#copyin +#user +#uncopyin +#match edward +#log +#next +8.2c 5 +9.1a 10 diff --git a/usr/lib/learn/files/L8.2c b/usr/lib/learn/files/L8.2c new file mode 100644 index 0000000000..9a8764632a --- /dev/null +++ b/usr/lib/learn/files/L8.2c @@ -0,0 +1,27 @@ +#print +As an example more complicated than you will +probably ever need, consider + ?[a-c]* +which matches what? Well the first character +can be anything; the second must be a, b, or c; and +nothing matters thereafter. So it matches + aaa + abc + xa + 3c25 +but not + a + ghi +and so forth. +Will it match + %a25 +Try some experiments, then type yes or no. +#create %a25 +#copyin +#user +#uncopyin +#match yes +#log +#next +9.1a 10 +9.2a 4 diff --git a/usr/lib/learn/files/L9.1a b/usr/lib/learn/files/L9.1a new file mode 100644 index 0000000000..2da6ae3789 --- /dev/null +++ b/usr/lib/learn/files/L9.1a @@ -0,0 +1,36 @@ +#print +The patterns for selecting file names that have been discussed +can be used with other commands than "ls". For example, +they can be used with the "cat" command to print files. +It is common for a memo stored in several +files to use files named "part1", "part2", etc. +so that commands like + cat part* +will print everything. +In this directory there are several +short files named "sec0", "sec1", "sec3", +and so forth. +There are various names of animals in the files; +find out the largest animal named in the files +and type "answer NAME" where NAME is that animal. +#create sec0 +dog mouse cat +#create sec1 +rabbit weasel +pig hamster +#create sec2 +this file doesn't happen +to have any animal names in it. +#create sec3 +fox elephant sheep +duck rat +#create sec4 +groundhog bobcat +mole beaver +#copyin +#user +#uncopyin +#match elephant +#log +#next +10.1a 10 diff --git a/usr/lib/learn/files/L9.2a b/usr/lib/learn/files/L9.2a new file mode 100644 index 0000000000..eac03df510 --- /dev/null +++ b/usr/lib/learn/files/L9.2a @@ -0,0 +1,30 @@ +#print +You can use patterns for file names with commands +other than "ls". For example, you can use them with +the "cat" command to print files. +This directory has three files named + parta + partb + partc +You can use + cat part? +to print all of them. Try that; then +type "ready". +#create parta +This is file parta; +it has two lines. +#create partb +File partb here - has only one line. +#create partc +And now in file partc, which has +the enormous total of +three lines. +#create partxxx +You shouldn't have printed this one. +#copyin +#user +#uncopyin +grep 'cat part?' .copy >/dev/null +#log +#next +9.2b 5 diff --git a/usr/lib/learn/files/L9.2b b/usr/lib/learn/files/L9.2b new file mode 100644 index 0000000000..64b9b0970d --- /dev/null +++ b/usr/lib/learn/files/L9.2b @@ -0,0 +1,22 @@ +#print +You can also use the "*" operator. For example, +print the contents of all the files in this +directory whose names begin with the letter 'p'. +Use just one "cat" command. +Then type "ready". +#create p1 +There are only two such files. This is the first +one and it is two lines long. +#create ppx + +This is the second file. Its first line +is blank, and then there are three lines of +text of which this is the last. +#copyin +#user +#uncopyin +grep 'cat p\*' .copy >/dev/null +#log +#next +10.1a 10 +9.2c 5 diff --git a/usr/lib/learn/files/L9.2c b/usr/lib/learn/files/L9.2c new file mode 100644 index 0000000000..ed1c330878 --- /dev/null +++ b/usr/lib/learn/files/L9.2c @@ -0,0 +1,26 @@ +#print +And as an example of the [] operators again, +print all the files in this directory whose +names begin with either 'a' or 'c'. +That will tell you to type either 'yes' +or 'no' - do what it says. +#create a1 +Type +#create a2 +y +#create b +n +o +#create cxx +e +#create cz23 +s +(on one line, please) +#copyin +#user +#uncopyin +#match yes +#log +#next +10.1a 10 +10.3a 2 diff --git a/usr/lib/learn/files/Lxxx b/usr/lib/learn/files/Lxxx new file mode 100644 index 0000000000..63e0543acf --- /dev/null +++ b/usr/lib/learn/files/Lxxx @@ -0,0 +1,41 @@ +#print +This course will help you learn about basic file +handling commands. You should first understand +the special characters # and @: + # cancels the previous character typed; + @ cancels the line being typed. +If you make a typing mistake, you can use these characters to +correct it before you finish the line and the computer won't +ever know about it. For example, what will the +computer really receive if you type + +st#he@ +thf#e + +at it? Reply "answer WORD" where WORD is the word +as it will be interpreted. For example, if +you think it will get 'dog', type + +answer dog + +If you think it will receive the word "bark", type + +answer bark + +Don't forget to leave a space between "answer" and the word +and to hit RETURN at the end of the line. +Don't use any quotation marks in your answer. +#copyin +#user +#uncopyin +#match dog +very funny, but i'll let you pass +#match the +that's the one i wanted +#match bark +very funny. good enough +#bad answerthe +don't type answerthe. try again. +#log +#next +0.1b 5