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