File:  [CSRG BSD Unix] / 43BSD / usr.lib / learn / editor / L10.1b
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#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
:"file" 6 lines, 89 characters
#create file
New York Mets Managers
 Casey Stengel
 Wes Westrum
 Gil Hodges
 Yogi Berra
 Roy McMillan
#copyout
#pipe
ex +'set prompt noopt open' file
#user
#unpipe
#uncopyout
tail -4 .ocopy >X1
#cmp X1 Ref 4
#fail
I hope you realized the addresses had to be
  $-2,$p
to get the last three lines.
#log
#next
11.1a 10
11.2a 5

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.