summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/editor/L10.1b
blob: 8cf203e74d3c9f010e3aff7323992e5edd9d3462 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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