]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/ed/ed.1
Merge bmake-20230909
[FreeBSD/FreeBSD.git] / bin / ed / ed.1
1 .Dd April 9, 2021
2 .Dt ED 1
3 .Os
4 .Sh NAME
5 .Nm ed ,
6 .Nm red
7 .Nd text editor
8 .Sh SYNOPSIS
9 .Nm
10 .Op Fl
11 .Op Fl s
12 .Op Fl p Ar string
13 .Op Ar file
14 .Nm red
15 .Op Fl
16 .Op Fl s
17 .Op Fl p Ar string
18 .Op Ar file
19 .Sh DESCRIPTION
20 The
21 .Nm
22 utility is a line-oriented text editor.
23 It is used to create, display, modify and otherwise manipulate text
24 files.
25 When invoked as
26 .Nm red ,
27 the editor runs in
28 .Qq restricted
29 mode, in which the only difference is that the editor restricts the
30 use of filenames which start with
31 .Ql \&!
32 (interpreted as shell commands by
33 .Nm )
34 or contain a
35 .Ql \&/ .
36 Note that editing outside of the current directory is only prohibited
37 if the user does not have write access to the current directory.
38 If a user has write access to the current directory, then symbolic
39 links can be created in the current directory, in which case
40 .Nm red
41 will not stop the user from editing the file that the symbolic link
42 points to.
43 .Pp
44 If invoked with a
45 .Ar file
46 argument, then a copy of
47 .Ar file
48 is read into the editor's buffer.
49 Changes are made to this copy and not directly to
50 .Ar file
51 itself.
52 Upon quitting
53 .Nm ,
54 any changes not explicitly saved with a
55 .Em w
56 command are lost.
57 .Pp
58 Editing is done in two distinct modes:
59 .Em command
60 and
61 .Em input .
62 When first invoked,
63 .Nm
64 is in command mode.
65 In this mode commands are read from the standard input and
66 executed to manipulate the contents of the editor buffer.
67 A typical command might look like:
68 .Pp
69 .Sm off
70 .Cm ,s No / Em old Xo
71 .No / Em new
72 .No / Cm g
73 .Xc
74 .Sm on
75 .Pp
76 which replaces all occurrences of the string
77 .Em old
78 with
79 .Em new .
80 .Pp
81 When an input command, such as
82 .Em a
83 (append),
84 .Em i
85 (insert) or
86 .Em c
87 (change), is given,
88 .Nm
89 enters input mode.
90 This is the primary means
91 of adding text to a file.
92 In this mode, no commands are available;
93 instead, the standard input is written
94 directly to the editor buffer.
95 Lines consist of text up to and
96 including a
97 .Em newline
98 character.
99 Input mode is terminated by
100 entering a single period
101 .Pq Em .\&
102 on a line.
103 .Pp
104 All
105 .Nm
106 commands operate on whole lines or ranges of lines; e.g.,
107 the
108 .Em d
109 command deletes lines; the
110 .Em m
111 command moves lines, and so on.
112 It is possible to modify only a portion of a line by means of replacement,
113 as in the example above.
114 However even here, the
115 .Em s
116 command is applied to whole lines at a time.
117 .Pp
118 In general,
119 .Nm
120 commands consist of zero or more line addresses, followed by a single
121 character command and possibly additional parameters; i.e.,
122 commands have the structure:
123 .Pp
124 .Sm off
125 .Xo
126 .Op Ar address Op , Ar address
127 .Ar command Op Ar parameters
128 .Xc
129 .Sm on
130 .Pp
131 The address(es) indicate the line or range of lines to be affected by the
132 command.
133 If fewer addresses are given than the command accepts, then
134 default addresses are supplied.
135 .Sh OPTIONS
136 The following options are available:
137 .Bl -tag -width indent
138 .It Fl s
139 Suppress diagnostics.
140 This should be used if
141 .Nm Ns 's
142 standard input is from a script.
143 .It Fl p Ar string
144 Specify a command prompt.
145 This may be toggled on and off with the
146 .Em P
147 command.
148 .It Ar file
149 Specify the name of a file to read.
150 If
151 .Ar file
152 is prefixed with a
153 bang (!), then it is interpreted as a shell command.
154 In this case,
155 what is read is
156 the standard output of
157 .Ar file
158 executed via
159 .Xr sh 1 .
160 To read a file whose name begins with a bang, prefix the
161 name with a backslash (\\).
162 The default filename is set to
163 .Ar file
164 only if it is not prefixed with a bang.
165 .El
166 .Sh LINE ADDRESSING
167 An address represents the number of a line in the buffer.
168 The
169 .Nm
170 utility maintains a
171 .Em current address
172 which is
173 typically supplied to commands as the default address when none is specified.
174 When a file is first read, the current address is set to the last line
175 of the file.
176 In general, the current address is set to the last line
177 affected by a command.
178 .Pp
179 A line address is
180 constructed from one of the bases in the list below, optionally followed
181 by a numeric offset.
182 The offset may include any combination
183 of digits, operators (i.e.,
184 .Em + ,
185 .Em -
186 and
187 .Em ^ )
188 and whitespace.
189 Addresses are read from left to right, and their values are computed
190 relative to the current address.
191 .Pp
192 One exception to the rule that addresses represent line numbers is the
193 address
194 .Em 0
195 (zero).
196 This means "before the first line,"
197 and is legal wherever it makes sense.
198 .Pp
199 An address range is two addresses separated either by a comma or
200 semi-colon.
201 The value of the first address in a range cannot exceed the
202 value of the second.
203 If only one address is given in a range, then
204 the second address is set to the given address.
205 If an
206 .Em n Ns -tuple
207 of addresses is given where
208 .Em "n\ >\ 2" ,
209 then the corresponding range is determined by the last two addresses in
210 the
211 .Em n Ns -tuple .
212 If only one address is expected, then the last address is used.
213 .Pp
214 Each address in a comma-delimited range is interpreted relative to the
215 current address.
216 In a semi-colon-delimited range, the first address is
217 used to set the current address, and the second address is interpreted
218 relative to the first.
219 .Pp
220 The following address symbols are recognized:
221 .Bl -tag -width indent
222 .It .
223 The current line (address) in the buffer.
224 .It $
225 The last line in the buffer.
226 .It n
227 The
228 .Em n Ns th
229 line in the buffer
230 where
231 .Em n
232 is a number in the range
233 .Em [0,$] .
234 .It - or ^
235 The previous line.
236 This is equivalent to
237 .Em -1
238 and may be repeated with cumulative effect.
239 .It -n or ^n
240 The
241 .Em n Ns th
242 previous line, where
243 .Em n
244 is a non-negative number.
245 .It +
246 The next line.
247 This is equivalent to
248 .Em +1
249 and may be repeated with cumulative effect.
250 .It +n
251 The
252 .Em n Ns th
253 next line, where
254 .Em n
255 is a non-negative number.
256 .It , or %
257 The first through last lines in the buffer.
258 This is equivalent to
259 the address range
260 .Em 1,$ .
261 .It ;
262 The current through last lines in the buffer.
263 This is equivalent to
264 the address range
265 .Em .,$ .
266 .It /re/
267 The next line containing the regular expression
268 .Em re .
269 The search wraps to the beginning of the buffer and continues down to the
270 current line, if necessary.
271 // repeats the last search.
272 .It ?re?
273 The
274 previous line containing the regular expression
275 .Em re .
276 The search wraps to the end of the buffer and continues up to the
277 current line, if necessary.
278 ?? repeats the last search.
279 .It 'lc
280 The
281 line previously marked by a
282 .Em k
283 (mark) command, where
284 .Em lc
285 is a lower case letter.
286 .El
287 .Sh REGULAR EXPRESSIONS
288 Regular expressions are patterns used in selecting text.
289 For example, the command:
290 .Pp
291 .Sm off
292 .Cm g No / Em string Xo
293 .No /
294 .Xc
295 .Sm on
296 .Pp
297 prints all lines containing
298 .Em string .
299 Regular expressions are also
300 used by the
301 .Em s
302 command for selecting old text to be replaced with new.
303 .Pp
304 In addition to a specifying string literals, regular expressions can
305 represent
306 classes of strings.
307 Strings thus represented are said to be matched
308 by the corresponding regular expression.
309 If it is possible for a regular expression
310 to match several strings in a line, then the left-most longest match is
311 the one selected.
312 .Pp
313 The following symbols are used in constructing regular expressions:
314 .Bl -tag -width indent
315 .It c
316 Any character
317 .Em c
318 not listed below, including
319 .Ql \&{ ,
320 .Ql \&} ,
321 .Ql \&( ,
322 .Ql \&) ,
323 .Ql <
324 and
325 .Ql > ,
326 matches itself.
327 .It Pf \e c
328 Any backslash-escaped character
329 .Em c ,
330 except for
331 .Ql \&{ ,
332 .Ql \&} ,
333 .Ql \&( ,
334 .Ql \&) ,
335 .Ql <
336 and
337 .Ql > ,
338 matches itself.
339 .It .
340 Match any single character.
341 .It Op char-class
342 Match any single character in
343 .Em char-class .
344 To include a
345 .Ql \&]
346 in
347 .Em char-class ,
348 it must be the first character.
349 A range of characters may be specified by separating the end characters
350 of the range with a
351 .Ql - ,
352 e.g.,
353 .Ql a-z
354 specifies the lower case characters.
355 The following literal expressions can also be used in
356 .Em char-class
357 to specify sets of characters:
358 .Pp
359 .Bl -column "[:alnum:]" "[:cntrl:]" "[:lower:]" "[:xdigit:]" -compact
360 .It [:alnum:] Ta [:cntrl:] Ta [:lower:] Ta [:space:]
361 .It [:alpha:] Ta [:digit:] Ta [:print:] Ta [:upper:]
362 .It [:blank:] Ta [:graph:] Ta [:punct:] Ta [:xdigit:]
363 .El
364 .Pp
365 If
366 .Ql -
367 appears as the first or last
368 character of
369 .Em char-class ,
370 then it matches itself.
371 All other characters in
372 .Em char-class
373 match themselves.
374 .Pp
375 Patterns in
376 .Em char-class
377 of the form:
378 .Pp
379 .Bl -item -compact -offset 2n
380 .It
381 .Op \&. Ns Ar col-elm Ns .\&
382 or,
383 .It
384 .Op = Ns Ar col-elm Ns =
385 .El
386 .Pp
387 where
388 .Ar col-elm
389 is a
390 .Em collating element
391 are interpreted according to the current locale settings
392 (not currently supported).
393 See
394 .Xr regex 3
395 and
396 .Xr re_format 7
397 for an explanation of these constructs.
398 .It Op ^char-class
399 Match any single character, other than newline, not in
400 .Em char-class .
401 .Em Char-class
402 is defined
403 as above.
404 .It ^
405 If
406 .Em ^
407 is the first character of a regular expression, then it
408 anchors the regular expression to the beginning of a line.
409 Otherwise, it matches itself.
410 .It $
411 If
412 .Em $
413 is the last character of a regular expression, it
414 anchors the regular expression to the end of a line.
415 Otherwise, it matches itself.
416 .It Pf \e <
417 Anchor the single character regular expression or subexpression
418 immediately following it to the beginning of a word.
419 (This may not be available)
420 .It Pf \e >
421 Anchor the single character regular expression or subexpression
422 immediately following it to the end of a word.
423 (This may not be available)
424 .It Pf \e (re\e)
425 Define a subexpression
426 .Em re .
427 Subexpressions may be nested.
428 A subsequent backreference of the form
429 .Pf \e Em n ,
430 where
431 .Em n
432 is a number in the range [1,9], expands to the text matched by the
433 .Em n Ns th
434 subexpression.
435 For example, the regular expression
436 .Ql \e(.*\e)\e1
437 matches any string
438 consisting of identical adjacent substrings.
439 Subexpressions are ordered relative to
440 their left delimiter.
441 .It *
442 Match the single character regular expression or subexpression
443 immediately preceding it zero or more times.
444 If
445 .Em *
446 is the first
447 character of a regular expression or subexpression, then it matches
448 itself.
449 The
450 .Em *
451 operator sometimes yields unexpected results.
452 For example, the regular expression
453 .Ql b*
454 matches the beginning of
455 the string
456 .Ql abbb
457 (as opposed to the substring
458 .Ql bbb ) ,
459 since a null match
460 is the only left-most match.
461 .It \e{n,m\e} or \e{n,\e} or \e{n\e}
462 Match the single character regular expression or subexpression
463 immediately preceding it at least
464 .Em n
465 and at most
466 .Em m
467 times.
468 If
469 .Em m
470 is omitted, then it matches at least
471 .Em n
472 times.
473 If the comma is also omitted, then it matches exactly
474 .Em n
475 times.
476 .El
477 .Pp
478 Additional regular expression operators may be defined depending on the
479 particular
480 .Xr regex 3
481 implementation.
482 .Sh COMMANDS
483 All
484 .Nm
485 commands are single characters, though some require additional parameters.
486 If a command's parameters extend over several lines, then
487 each line except for the last
488 must be terminated with a backslash (\\).
489 .Pp
490 In general, at most one command is allowed per line.
491 However, most commands accept a print suffix, which is any of
492 .Em p
493 (print),
494 .Em l
495 (list),
496 or
497 .Em n
498 (enumerate),
499 to print the last line affected by the command.
500 .Pp
501 An interrupt (typically ^C) has the effect of aborting the current command
502 and returning the editor to command mode.
503 .Pp
504 The
505 .Nm
506 utility
507 recognizes the following commands.
508 The commands are shown together with
509 the default address or address range supplied if none is
510 specified (in parenthesis).
511 .Bl -tag -width indent
512 .It (.)a
513 Append text to the buffer after the addressed line.
514 Text is entered in input mode.
515 The current address is set to last line entered.
516 .It (.,.)c
517 Change lines in the buffer.
518 The addressed lines are deleted
519 from the buffer, and text is appended in their place.
520 Text is entered in input mode.
521 The current address is set to last line entered.
522 .It (.,.)d
523 Delete the addressed lines from the buffer.
524 If there is a line after the deleted range, then the current address is set
525 to this line.
526 Otherwise the current address is set to the line
527 before the deleted range.
528 .It e Ar file
529 Edit
530 .Ar file ,
531 and sets the default filename.
532 If
533 .Ar file
534 is not specified, then the default filename is used.
535 Any lines in the buffer are deleted before
536 the new file is read.
537 The current address is set to the last line read.
538 .It e Ar !command
539 Edit the standard output of
540 .Ar !command ,
541 (see
542 .Ar !command
543 below).
544 The default filename is unchanged.
545 Any lines in the buffer are deleted before the output of
546 .Ar command
547 is read.
548 The current address is set to the last line read.
549 .It E Ar file
550 Edit
551 .Ar file
552 unconditionally.
553 This is similar to the
554 .Em e
555 command,
556 except that unwritten changes are discarded without warning.
557 The current address is set to the last line read.
558 .It f Ar file
559 Set the default filename to
560 .Ar file .
561 If
562 .Ar file
563 is not specified, then the default unescaped filename is printed.
564 .It (1,$)g/re/command-list
565 Apply
566 .Ar command-list
567 to each of the addressed lines matching a regular expression
568 .Ar re .
569 The current address is set to the
570 line currently matched before
571 .Ar command-list
572 is executed.
573 At the end of the
574 .Em g
575 command, the current address is set to the last line affected by
576 .Ar command-list .
577 .Pp
578 Each command in
579 .Ar command-list
580 must be on a separate line,
581 and every line except for the last must be terminated by a backslash
582 (\\).
583 Any commands are allowed, except for
584 .Em g ,
585 .Em G ,
586 .Em v ,
587 and
588 .Em V .
589 A newline alone in
590 .Ar command-list
591 is equivalent to a
592 .Em p
593 command.
594 .It (1,$)G/re/
595 Interactively edit the addressed lines matching a regular expression
596 .Ar re .
597 For each matching line,
598 the line is printed,
599 the current address is set,
600 and the user is prompted to enter a
601 .Ar command-list .
602 At the end of the
603 .Em G
604 command, the current address
605 is set to the last line affected by (the last)
606 .Ar command-list .
607 .Pp
608 The format of
609 .Ar command-list
610 is the same as that of the
611 .Em g
612 command.
613 A newline alone acts as a null command list.
614 A single
615 .Ql &
616 repeats the last non-null command list.
617 .It H
618 Toggle the printing of error explanations.
619 By default, explanations are not printed.
620 It is recommended that ed scripts begin with this command to
621 aid in debugging.
622 .It h
623 Print an explanation of the last error.
624 .It (.)i
625 Insert text in the buffer before the current line.
626 Text is entered in input mode.
627 The current address is set to the last line entered.
628 .It (.,.+1)j
629 Join the addressed lines.
630 The addressed lines are
631 deleted from the buffer and replaced by a single
632 line containing their joined text.
633 The current address is set to the resultant line.
634 .It (.)klc
635 Mark a line with a lower case letter
636 .Em lc .
637 The line can then be addressed as
638 .Em 'lc
639 (i.e., a single quote followed by
640 .Em lc )
641 in subsequent commands.
642 The mark is not cleared until the line is
643 deleted or otherwise modified.
644 .It (.,.)l
645 Print the addressed lines unambiguously.
646 If a single line fills more than one screen (as might be the case
647 when viewing a binary file, for instance), a
648 .Dq Li --More--
649 prompt is printed on the last line.
650 The
651 .Nm
652 utility waits until the RETURN key is pressed
653 before displaying the next screen.
654 The current address is set to the last line
655 printed.
656 .It (.,.)m(.)
657 Move lines in the buffer.
658 The addressed lines are moved to after the
659 right-hand destination address, which may be the address
660 .Em 0
661 (zero).
662 The current address is set to the
663 last line moved.
664 .It (.,.)n
665 Print the addressed lines along with
666 their line numbers.
667 The current address is set to the last line
668 printed.
669 .It (.,.)p
670 Print the addressed lines.
671 The current address is set to the last line
672 printed.
673 .It P
674 Toggle the command prompt on and off.
675 Unless a prompt was specified by with command-line option
676 .Fl p Ar string ,
677 the command prompt is by default turned off.
678 .It q
679 Quit
680 .Nm .
681 .It Q
682 Quit
683 .Nm
684 unconditionally.
685 This is similar to the
686 .Em q
687 command,
688 except that unwritten changes are discarded without warning.
689 .It ($)r Ar file
690 Read
691 .Ar file
692 to after the addressed line.
693 If
694 .Ar file
695 is not specified, then the default
696 filename is used.
697 If there was no default filename prior to the command,
698 then the default filename is set to
699 .Ar file .
700 Otherwise, the default filename is unchanged.
701 The current address is set to the last line read.
702 .It ($)r Ar !command
703 Read
704 to after the addressed line
705 the standard output of
706 .Ar !command ,
707 (see the
708 .Ar !command
709 below).
710 The default filename is unchanged.
711 The current address is set to the last line read.
712 .It (.,.)s/re/replacement/
713 .It (.,.)s/re/replacement/g
714 .It (.,.)s/re/replacement/n
715 Replace text in the addressed lines
716 matching a regular expression
717 .Ar re
718 with
719 .Ar replacement .
720 By default, only the first match in each line is replaced.
721 If the
722 .Em g
723 (global) suffix is given, then every match to be replaced.
724 The
725 .Em n
726 suffix, where
727 .Em n
728 is a positive number, causes only the
729 .Em n Ns th
730 match to be replaced.
731 It is an error if no substitutions are performed on any of the addressed
732 lines.
733 The current address is set the last line affected.
734 .Pp
735 .Ar \&Re
736 and
737 .Ar replacement
738 may be delimited by any character other than space and newline
739 (see the
740 .Em s
741 command below).
742 If one or two of the last delimiters is omitted, then the last line
743 affected is printed as though the print suffix
744 .Em p
745 were specified.
746 .Pp
747 An unescaped
748 .Ql &
749 in
750 .Ar replacement
751 is replaced by the currently matched text.
752 The character sequence
753 .Em \em ,
754 where
755 .Em m
756 is a number in the range [1,9], is replaced by the
757 .Em m th
758 backreference expression of the matched text.
759 If
760 .Ar replacement
761 consists of a single
762 .Ql % ,
763 then
764 .Ar replacement
765 from the last substitution is used.
766 Newlines may be embedded in
767 .Ar replacement
768 if they are escaped with a backslash (\\).
769 .It (.,.)s
770 Repeat the last substitution.
771 This form of the
772 .Em s
773 command accepts a count suffix
774 .Em n ,
775 or any combination of the characters
776 .Em r ,
777 .Em g ,
778 and
779 .Em p .
780 If a count suffix
781 .Em n
782 is given, then only the
783 .Em n Ns th
784 match is replaced.
785 The
786 .Em r
787 suffix causes
788 the regular expression of the last search to be used instead of the
789 that of the last substitution.
790 The
791 .Em g
792 suffix toggles the global suffix of the last substitution.
793 The
794 .Em p
795 suffix toggles the print suffix of the last substitution
796 The current address is set to the last line affected.
797 .It (.,.)t(.)
798 Copy (i.e., transfer) the addressed lines to after the right-hand
799 destination address, which may be the address
800 .Em 0
801 (zero).
802 The current address is set to the last line
803 copied.
804 .It u
805 Undo the last command and restores the current address
806 to what it was before the command.
807 The global commands
808 .Em g ,
809 .Em G ,
810 .Em v ,
811 and
812 .Em V .
813 are treated as a single command by undo.
814 .Em u
815 is its own inverse.
816 .It (1,$)v/re/command-list
817 Apply
818 .Ar command-list
819 to each of the addressed lines not matching a regular expression
820 .Ar re .
821 This is similar to the
822 .Em g
823 command.
824 .It (1,$)V/re/
825 Interactively edit the addressed lines not matching a regular expression
826 .Ar re .
827 This is similar to the
828 .Em G
829 command.
830 .It (1,$)w Ar file
831 Write the addressed lines to
832 .Ar file .
833 Any previous contents of
834 .Ar file
835 is lost without warning.
836 If there is no default filename, then the default filename is set to
837 .Ar file ,
838 otherwise it is unchanged.
839 If no filename is specified, then the default
840 filename is used.
841 The current address is unchanged.
842 .It (1,$)wq Ar file
843 Write the addressed lines to
844 .Ar file ,
845 and then executes a
846 .Em q
847 command.
848 .It (1,$)w Ar !command
849 Write the addressed lines to the standard input of
850 .Ar !command ,
851 (see the
852 .Em !command
853 below).
854 The default filename and current address are unchanged.
855 .It (1,$)W Ar file
856 Append the addressed lines to the end of
857 .Ar file .
858 This is similar to the
859 .Em w
860 command, expect that the previous contents of file is not clobbered.
861 The current address is unchanged.
862 .It Pf (.+1)z n
863 Scroll
864 .Ar n
865 lines at a time starting at addressed line.
866 If
867 .Ar n
868 is not specified, then the current window size is used.
869 The current address is set to the last line printed.
870 .It !command
871 Execute
872 .Ar command
873 via
874 .Xr sh 1 .
875 If the first character of
876 .Ar command
877 is
878 .Ql \&! ,
879 then it is replaced by text of the
880 previous
881 .Ar !command .
882 The
883 .Nm
884 utility does not process
885 .Ar command
886 for backslash (\\) escapes.
887 However, an unescaped
888 .Em %
889 is replaced by the default filename.
890 When the shell returns from execution, a
891 .Ql \&!
892 is printed to the standard output.
893 The current line is unchanged.
894 .It ($)=
895 Print the line number of the addressed line.
896 .It (.+1)newline
897 Print the addressed line, and sets the current address to
898 that line.
899 .El
900 .Sh FILES
901 .Bl -tag -width /tmp/ed.* -compact
902 .It Pa /tmp/ed.*
903 buffer file
904 .It Pa ed.hup
905 the file to which
906 .Nm
907 attempts to write the buffer if the terminal hangs up
908 .El
909 .Sh DIAGNOSTICS
910 When an error occurs,
911 .Nm
912 prints a
913 .Ql \&?
914 and either returns to command mode
915 or exits if its input is from a script.
916 An explanation of the last error can be
917 printed with the
918 .Em h
919 (help) command.
920 .Pp
921 Since the
922 .Em g
923 (global) command masks any errors from failed searches and substitutions,
924 it can be used to perform conditional operations in scripts; e.g.,
925 .Pp
926 .Sm off
927 .Cm g No / Em old Xo
928 .No / Cm s
929 .No // Em new
930 .No /
931 .Xc
932 .Sm on
933 .Pp
934 replaces any occurrences of
935 .Em old
936 with
937 .Em new .
938 If the
939 .Em u
940 (undo) command occurs in a global command list, then
941 the command list is executed only once.
942 .Pp
943 If diagnostics are not disabled, attempting to quit
944 .Nm
945 or edit another file before writing a modified buffer
946 results in an error.
947 If the command is entered a second time, it succeeds,
948 but any changes to the buffer are lost.
949 .Sh SEE ALSO
950 .Xr sed 1 ,
951 .Xr sh 1 ,
952 .Xr vi 1 ,
953 .Xr regex 3
954 .Pp
955 USD:12-13
956 .Rs
957 .%A B. W. Kernighan
958 .%A P. J. Plauger
959 .%B Software Tools in Pascal
960 .%O Addison-Wesley
961 .%D 1981
962 .Re
963 .Rs
964 .\" 4.4BSD USD:9
965 .%A B. W. Kernighan
966 .%T A Tutorial Introduction to the UNIX Text Editor
967 .Re
968 .Rs
969 .\" 4.4BSD USD:10
970 .%A B. W. Kernighan
971 .%T Advanced Editing on UNIX
972 .Re
973 .Sh LIMITATIONS
974 The
975 .Nm
976 utility processes
977 .Ar file
978 arguments for backslash escapes, i.e., in a filename,
979 any characters preceded by a backslash (\\) are
980 interpreted literally.
981 .Pp
982 If a text (non-binary) file is not terminated by a newline character,
983 then
984 .Nm
985 appends one on reading/writing it.
986 In the case of a binary file,
987 .Nm
988 does not append a newline on reading/writing.
989 .Pp
990 per line overhead: 4 ints
991 .Sh HISTORY
992 An
993 .Nm
994 command appeared in
995 .At v1 .
996 .Sh BUGS
997 The
998 .Nm
999 utility does not recognize multibyte characters.