1ed(1) User Commands ed(1)
2
3
4
6 ed, red - text editor
7
9 /usr/bin/ed [-s | -] [-p string] [-x] [-C] [file]
10
11
12 /usr/xpg4/bin/ed [-s | -] [-p string] [-x] [-C] [file]
13
14
15 /usr/xpg6/bin/ed [-s | -] [-p string] [-x] [-C] [file]
16
17
18 /usr/bin/red [-s | -] [-p string] [-x] [-C] [file]
19
20
22 The ed utility is the standard text editor. If file is specified, ed
23 simulates an e command (see below) on the named file. That is, the file
24 is read into ed's buffer so that it can be edited.
25
26
27 The ed utility operates on a copy of the file it is editing. Changes
28 made to the copy have no effect on the file until a w (write) command
29 is given. The copy of the text being edited resides in a temporary file
30 called the buffer. There is only one buffer.
31
32
33 The red utility is a restricted version of ed. It will only allow edit‐
34 ing of files in the current directory. red prohibits executing shell
35 commands via !shell command. Attempts to bypass these restrictions
36 result in an error message (restricted shell).
37
38
39 Both ed and red support the fspec(4) formatting capability. The default
40 terminal mode is either stty -tabs or stty tab3, where tab stops are
41 set at eight columns (see stty(1)). If, however, the first line of file
42 contains a format specification, that specification will override the
43 default mode. For example, tab stops would be set at 5, 10, and 15, and
44 a maximum line length of 72 would be imposed if the first line of file
45 contains
46
47 <:t5,10,15 s72:>
48
49
50
51
52 Commands to ed have a simple and regular structure: zero, one, or two
53 addresses followed by a single-character command, possibly followed by
54 parameters to that command. These addresses specify one or more lines
55 in the buffer. Every command that requires addresses has default
56 addresses, so that the addresses can very often be omitted.
57
58
59 In general, only one command may appear on a line. Certain commands
60 allow the input of text. This text is placed in the appropriate place
61 in the buffer. While ed is accepting text, it is said to be in input
62 mode. In this mode, no commands are recognized; all input is merely
63 collected. Leave input mode by typing a period (.) at the beginning of
64 a line, followed immediately by a carriage return.
65
66 /usr/bin/ed
67 If ed executes commands with arguments, it uses the default shell
68 /usr/bin/sh (see sh(1)).
69
70 /usr/xpg4/bin/ed and /usr/xpg6/bin/ed
71 If ed executes commands with arguments, it uses /usr/xpg4/bin/sh (see
72 ksh(1)).
73
74 Regular Expressions
75 The ed utility supports a limited form of regular expression notation.
76 Regular expressions are used in addresses to specify lines and in some
77 commands (for example, s) to specify portions of a line that are to be
78 substituted. To understand addressing in ed, it is necessary to know
79 that at any time there is a current line. Generally speaking, the cur‐
80 rent line is the last line affected by a command. The exact effect on
81 the current line is discussed under the description of each command.
82
83
84 Internationalized Basic Regular Expressions are used for all system-
85 supplied locales. See regex(5).
86
87 ed Commands
88 Commands may require zero, one, or two addresses. Commands that require
89 no addresses regard the presence of an address as an error. Commands
90 that accept one or two addresses assume default addresses when an
91 insufficient number of addresses is given; if more addresses are given
92 than such a command requires, the last one(s) are used.
93
94
95 Typically, addresses are separated from each other by a comma (,). They
96 may also be separated by a semicolon (;). In the latter case, the first
97 address is calculated, the current line (.) is set to that value, and
98 then the second address is calculated. This feature can be used to
99 determine the starting line for forward and backward searches (see
100 Rules 5 and 6, above). The second address of any two-address sequence
101 must correspond to a line in the buffer that follows the line corre‐
102 sponding to the first address.
103
104
105 For /usr/xpg6/gbin/ed, the address can be omitted on either side of the
106 comma or semicolon separator, in which case the resulting address pairs
107 are as follows:
108
109
110
111
112 ┌─────────────────────────────┬─────────────────────────────┐
113 │ Specified │ Resulting │
114 ├─────────────────────────────┼─────────────────────────────┤
115 │, │1 , $ │
116 ├─────────────────────────────┼─────────────────────────────┤
117 │, addr │1 , addr │
118 ├─────────────────────────────┼─────────────────────────────┤
119 │addr , │addr , addr │
120 ├─────────────────────────────┼─────────────────────────────┤
121 │; │1 ; $ │
122 ├─────────────────────────────┼─────────────────────────────┤
123 │; addr │1 ; addr │
124 ├─────────────────────────────┼─────────────────────────────┤
125 │addr ; │addr ; addr │
126 └─────────────────────────────┴─────────────────────────────┘
127
128
129 Any <blank>s included between addresses, address separators, or address
130 offsets are ignored.
131
132
133 In the following list of ed commands, the parentheses shown prior to
134 the command are not part of the address. Rather, the parentheses show
135 the default address(es) for the command.
136
137
138 Each address component can be preceded by zero or more blank charac‐
139 ters. The command letter can be preceded by zero or more blank charac‐
140 ters. If a suffix letter (l, n, or p) is given, it must immediately
141 follow the command.
142
143
144 The e, E, f, r, and w commands take an optional file parameter, sepa‐
145 rated from the command letter by one or more blank characters.
146
147
148 If changes have been made in the buffer since the last w command that
149 wrote the entire buffer, ed warns the user if an attempt is made to
150 destroy the editor buffer via the e or q commands. The ed utility
151 writes the string:
152
153 "?\n"
154
155
156
157
158 (followed by an explanatory message if help mode has been enabled via
159 the H command) to standard output and continues in command mode with
160 the current line number unchanged. If the e or q command is repeated
161 with no intervening command, ed takes effect.
162
163
164 If an end-of-file is detected on standard input when a command is
165 expected, the ed utility acts as if a q command had been entered.
166
167
168 It is generally illegal for more than one command to appear on a line.
169 However, any command (except e, f, r, or w) may be suffixed by l, n, or
170 p in which case the current line is either listed, numbered or written,
171 respectively, as discussed below under the l, n, and p commands.
172
173 (.)a The append command accepts zero or more lines of text and
174 <text> appends it after the addressed line in the buffer. The cur‐
175 . rent line (.) is left at the last inserted line, or, if
176 there were none, at the addressed line. Address 0 is legal
177 for this command: it causes the ``appended'' text to be
178 placed at the beginning of the buffer. The maximum number of
179 characters that may be entered from a terminal is 256 per
180 line (including the new-line character).
181
182
183 (.,.)c The change command deletes the addressed lines from the buf‐
184 <text> fer, then accepts zero or more lines of text that replaces
185 . these lines in the buffer. The current line (.) is left at
186 the last line input, or, if there were none, at the first
187 line that was not deleted. If the lines deleted were origi‐
188 nally at the end of the buffer, the current line number will
189 be set to the address of the new last line. If no lines
190 remain in the buffer, the current line number will be set to
191 0.
192
193 /usr/xpg4/bin/ed Address 0 is not legal for this command.
194
195
196 /usr/xpg6/bin/ed Address 0 is valid for this command. It
197 is interpreted as if the address 1 were
198 specified.
199
200
201
202 C Same as the X command, described later, except that ed
203 assumes all text read in for the e and r commands is
204 encrypted unless a null key is typed in.
205
206
207 (.,.)d The delete command deletes the addressed lines from the buf‐
208 fer. The line after the last line deleted becomes the cur‐
209 rent line. If the lines deleted were originally at the end
210 of the buffer, the new last line becomes the current line.
211 If no lines remain in the buffer, the current line number
212 will be set to 0.
213
214
215 e file The edit command deletes the entire contents of the buffer
216 and then reads the contents of file into the buffer. The
217 current line (.) is set to the last line of the buffer. If
218 file is not given, the currently remembered file name, if
219 any, is used (see the f command). The number of bytes read
220 will be written to standard output, unless the -s option was
221 specified, in the following format:
222
223 "%d\n" <number of bytes read>
224
225 file is remembered for possible use as a default file name
226 in subsequent e, E, r, and w commands. If file is replaced
227 by !, the rest of the line is taken to be a shell ( sh(1))
228 command whose output is to be read. Such a shell command is
229 not remembered as the current file name. See also DIAGNOS‐
230 TICS below. All marks are discarded upon the completion of a
231 successful e command. If the buffer has changed since the
232 last time the entire buffer was written, the user is warned,
233 as described previously.
234
235
236 E file The Edit command is like e, except that the editor does not
237 check to see if any changes have been made to the buffer
238 since the last w command.
239
240
241 f file If file is given, the f command changes the currently remem‐
242 bered path name to file. Whether the name is changed or not,
243 the f command then writes the (possibly new) currently
244 remembered path name to the standard output in the following
245 format:
246
247 "%s\n"pathname
248
249 The current line number is unchanged.
250
251
252 (1,$)g/RE/command list In the global command, the first step is to
253 mark every line that matches the given RE.
254 Then, for every such line, the given command
255 list is executed with the current line (.)
256 initially set to that line. When the g com‐
257 mand completes, the current line number has
258 the value assigned by the last command in the
259 command list. If there were no matching
260 lines, the current line number is not
261 changed. A single command or the first of a
262 list of commands appears on the same line as
263 the global command. All lines of a multi-line
264 list except the last line must be ended with
265 a backslash (\); a, i, and c commands and
266 associated input are permitted. The . termi‐
267 nating input mode may be omitted if it would
268 be the last line of the command list. An
269 empty command list is equivalent to the p
270 command. The g, G, v, V, and ! commands are
271 not permitted in the command list. See also
272 the NOTES and the last paragraph before FILES
273 below. Any character other than space or new‐
274 line can be used instead of a slash to
275 delimit the RE. Within the RE, the RE delim‐
276 iter itself can be used as a literal charac‐
277 ter if it is preceded by a backslash.
278
279
280 (1,$)G/RE/ In the interactive Global command, the first
281 step is to mark every line that matches the
282 given RE. Then, for every such line, that
283 line is written to standard output, the cur‐
284 rent line (.) is changed to that line, and
285 any one command (other than one of the a, c,
286 i, g, G, v, and V commands) may be input and
287 is executed. After the execution of that com‐
288 mand, the next marked line is written, and so
289 on. A new-line acts as a null command. An &
290 causes the re-execution of the most recent
291 non-null command executed within the current
292 invocation of G. Note: The commands input as
293 part of the execution of the G command may
294 address and affect any lines in the buffer.
295 The final value of the current line number is
296 the value set by the last command success‐
297 fully executed. (Notice that the last command
298 successfully executed is the G command itself
299 if a command fails or the null command is
300 specified.) If there were no matching lines,
301 the current line number is not changed. The G
302 command can be terminated by a SIGINT signal.
303 The G command can be terminated by an inter‐
304 rupt signal (ASCII DEL or BREAK). Any charac‐
305 ter other than space or newline can be used
306 instead of a slash to delimit the RE. Within
307 the RE, the RE delimiter itself can be used
308 as a literal character if it is preceded by a
309 backslash.
310
311
312 h The help command gives a short error message
313 that explains the reason for the most recent
314 ? diagnostic. The current line number is
315 unchanged.
316
317
318 H The Help command causes ed to enter a mode in
319 which error messages are written for all sub‐
320 sequent ? diagnostics. It also explains the
321 previous ? if there was one. The H command
322 alternately turns this mode on and off; it is
323 initially off. The current line number is
324 unchanged.
325
326
327 (.,.)i The insert command accepts zero or more lines
328 <text> of text and inserts it before the addressed
329 . line in the buffer. The current line (.) is
330 left at the last inserted line, or, if there
331 were none, at the addressed line. This com‐
332 mand differs from the a command only in the
333 placement of the input text. The maximum num‐
334 ber of characters that may be entered from a
335 terminal is 256 per line (including the new-
336 line character).
337
338 /usr/xpg4/bin/ed Address 0 is not legal
339 for this command.
340
341
342 /usr/xpg6/bin/ed Address 0 is valid for
343 this command. It is
344 interpreted as if the
345 address 1 were specified.
346
347
348
349 (.,.+1)j The join command joins contiguous lines by
350 removing the appropriate new-line characters.
351 If exactly one address is given, this command
352 does nothing. If lines are joined, the cur‐
353 rent line number is set to the address of the
354 joined line. Otherwise, the current line num‐
355 ber is unchanged.
356
357
358 (.)kx The mark command marks the addressed line
359 with name x, which must be an ASCII lower-
360 case letter (a-z). The address a´x then
361 addresses this line. The current line (.) is
362 unchanged.
363
364
365 (.,.)l The l command writes to standard output the
366 addressed lines in a visually unambiguous
367 form. The characters ( \\, \a, \b, \f, \r,
368 \t, \v) are written as the corresponding
369 escape sequence. The \n in that table is not
370 applicable. Non-printable characters not in
371 the table are written as one three-digit
372 octal number (with a preceding backslash
373 character) for each byte in the character,
374 with the most significant byte first.
375
376 Long lines are folded, with the point of
377 folding indicated by writing backslash/new‐
378 line character. The length at which folding
379 occurs is unspecified, but should be appro‐
380 priate for the output device. The end of each
381 line is marked with a $. When using the
382 /usr/xpg6/bin/ed command, the end of each
383 line is marked with a $ due to folding, and $
384 characters within the text are written with a
385 preceding backslash. An l command can be
386 appended to any other command other than e,
387 E, f, q, Q, r, w, or !. The current line num‐
388 ber is set to the address of the last line
389 written.
390
391
392 (.,.)ma The move command repositions the addressed
393 line(s) after the line addressed by a.
394 Address 0 is legal for a and causes the
395 addressed line(s) to be moved to the begin‐
396 ning of the file. It is an error if address a
397 falls within the range of moved lines. The
398 current line (.) is left at the last line
399 moved.
400
401
402 (.,.)n The number command writes the addressed
403 lines, preceding each line by its line number
404 and a tab character. The current line (.) is
405 left at the last line written. The n command
406 may be appended to any command other than e,
407 E, f, q, Q, r, w, or !.
408
409
410 (.,.)p The print command writes the addressed lines
411 to standard output. The current line (.) is
412 left at the last line written. The p command
413 may be appended to any command other than e,
414 E, f, q, Q, r, w, or !. For example, dp
415 deletes the current line and writes the new
416 current line.
417
418
419 P The P command causes ed to prompt with an
420 asterisk (*) (or string, if -p is specified)
421 for all subsequent commands. The P command
422 alternatively turns this mode on and off; it
423 is initially on if the -p option is speci‐
424 fied, otherwise off. The current line is
425 unchanged.
426
427
428 q The quit command causes ed to exit. If the
429 buffer has changed since the last time the
430 entire buffer was written, the user is
431 warned. See DIAGNOSTICS.
432
433
434 Q The editor exits without checking if changes
435 have been made in the buffer since the last w
436 command.
437
438
439 ($)r file The read command reads the contents of file
440 into the buffer. If file is not given, the
441 currently remembered file name, if any, is
442 used (see the e and f commands). The cur‐
443 rently remembered file name is not changed
444 unless file is the very first file name men‐
445 tioned since ed was invoked. Address 0 is
446 legal for r and causes the file to be read in
447 at the beginning of the buffer. If the read
448 is successful and the -s option was not spec‐
449 ified, the number of characters read is writ‐
450 ten to standard output in the following for‐
451 mat:
452
453 %d\n, <number of bytes read>
454
455
456 The current line (.) is set to the last line
457 read. If file is replaced by !, the rest of
458 the line is taken to be a shell command (see
459 sh(1)) whose output is to be read. For exam‐
460 ple, $r !ls appends the current directory to
461 the end of the file being edited. Such a
462 shell command is not remembered as the cur‐
463 rent file name.
464
465
466 (.,.)s/RE/replacement/
467 (.,.)s/RE/replacement/count, count=[1-2047]
468 (.,.)s/RE/replacement/g
469 (.,.)s/RE/replacement/l
470 (.,.)s/RE/replacement/n
471 (.,.)s/RE/replacement/p
472
473 The substitute command searches each addressed line for an occur‐
474 rence of the specified RE. Zero or more substitution commands can
475 be specified. In each line in which a match is found, all (non-
476 overlapped) matched strings are replaced by the replacement if the
477 global replacement indicator g appears after the command. If the
478 global indicator does not appear, only the first occurrence of the
479 matched string is replaced. If a number count appears after the
480 command, only the count-th occurrence of the matched string on each
481 addressed line is replaced. It is an error if the substitution
482 fails on all addressed lines. Any character other than space or
483 new-line may be used instead of the slash (/) to delimit the RE and
484 the replacement. The current line (.) is left at the last line on
485 which a substitution occurred. Within the RE, the RE delimiter
486 itself can be used as a literal character if it is preceded by a
487 backslash. See also the last paragraph before FILES below.
488
489 An ampersand (&) appearing in the replacement is replaced by the
490 string matching the RE on the current line. The special meaning of
491 & in this context may be suppressed by preceding it by \. As a more
492 general feature, the characters \n, where n is a digit, are
493 replaced by the text matched by the n-th regular subexpression of
494 the specified RE enclosed between \( and \). When nested parenthe‐
495 sized subexpressions are present, n is determined by counting
496 occurrences of \( starting from the left. When the character % is
497 the only character in the replacement, the replacement used in the
498 most recent substitute command is used as the replacement in the
499 current substitute command. If there was no previous substitute
500 command, the use of % in this manner is an error. The % loses its
501 special meaning when it is in a replacement string of more than one
502 character or is preceded by a \. For each backslash (\) encountered
503 in scanning replacement from beginning to end, the following char‐
504 acter loses its special meaning (if any). It is unspecified what
505 special meaning is given to any character other than &, \, %, or
506 digits.
507
508 A line may be split by substituting a new-line character into it.
509 The new-line in the replacement must be escaped by preceding it by
510 \. Such substitution cannot be done as part of a g or v command
511 list. The current line number is set to the address of the last
512 line on which a substitution is performed. If no substitution is
513 performed, the current line number is unchanged. If a line is
514 split, a substitution is considered to have been performed on each
515 of the new lines for the purpose of determining the new current
516 line number. A substitution is considered to have been performed
517 even if the replacement string is identical to the string that it
518 replaces.
519
520 The substitute command supports the following indicators:
521
522 count Substitute for the countth occurrence only of the RE found
523 on each addressed line. count must be between 1-2047.
524
525
526 g Globally substitute for all non-overlapping instances of
527 the RE rather than just the first one. If both g and count
528 are specified, the results are unspecified.
529
530
531 l Write to standard output the final line in which a substi‐
532 tution was made. The line is written in the format speci‐
533 fied for the l command.
534
535
536 n Write to standard output the final line in which a substi‐
537 tution was made. The line is written in the format speci‐
538 fied for the n command.
539
540
541 p Write to standard output the final line in which a substi‐
542 tution was made. The line will be written in the format
543 specified for the p command.
544
545
546
547 (.,.)ta
548
549 This command acts just like the m command, except that a copy of
550 the addressed lines is placed after address a (which may be 0). The
551 current line (.) is left at the last line copied.
552
553
554 u
555
556 The undo command nullifies the effect of the most recent command
557 that modified anything in the buffer, namely the most recent a, c,
558 d, g, i, j, m, r, s, t, u, v, G, or V command. All changes made to
559 the buffer by a g, G, v, or V global command is undone as a single
560 change.If no changes were made by the global command (such as with
561 g/ RE/p), the u command has no effect. The current line number is
562 set to the value it had immediately before the command being
563 undone started.
564
565
566 (1,$)v/RE/command list
567
568 This command is the same as the global command g, except that the
569 lines marked during the first step are those that do not match the
570 RE.
571
572
573 (1,$)V/RE/
574
575 This command is the same as the interactive global command G,
576 except that the lines that are marked during the first step are
577 those that do not match the RE.
578
579
580 (1,$)w file
581
582 The write command writes the addressed lines into file. If file
583 does not exist, it is created with mode 666 (readable and writable
584 by everyone), unless your file creation mask dictates otherwise.
585 See the description of the umask special command on sh(1). The cur‐
586 rently remembered file name is not changed unless file is the very
587 first file name mentioned since ed was invoked. If no file name is
588 given, the currently remembered file name, if any, is used (see the
589 e and f commands). The current line (.) is unchanged. If the com‐
590 mand is successful, the number of characters written is printed,
591 unless the -s option is specified in the following format:
592
593 "%d\n",<number of bytes written>
594
595
596 If file is replaced by !, the rest of the line is taken to be a
597 shell (see sh(1)) command whose standard input is the addressed
598 lines. Such a shell command is not remembered as the current path
599 name. This usage of the write command with ! is to be considered as
600 a ``last w command that wrote the entire buffer''.
601
602
603 (1,$)W file This command is the same as the write command above,
604 except that it appends the addressed lines to the
605 end of file if it exists. If file does not exist, it
606 is created as described above for the w command.
607
608
609 X An educated guess is made to determine whether text
610 read for the e and r commands is encrypted. A null
611 key turns off encryption. Subsequent e, r, and w
612 commands will use this key to encrypt or decrypt the
613 text. An explicitly empty key turns off encryption.
614 Also, see the -x option of ed.
615
616
617 ($)= The line number of the addressed line is written to
618 standard output in the following format:
619
620 "%d\n"<line number>
621
622
623 The current line number is unchanged by this com‐
624 mand.
625
626
627 !shell command The remainder of the line after the ! is sent to the
628 UNIX system shell (see sh(1)) to be interpreted as a
629 command. Within the text of that command, the
630 unescaped character % is replaced with the remem‐
631 bered file name. If a ! appears as the first charac‐
632 ter of the shell command, it is replaced with the
633 text of the previous shell command. Thus, !! repeats
634 the last shell command. If any replacements of % or
635 ! are performed, the modified line is written to the
636 standard output before command is executed. The !
637 command will write:
638
639 "!\n"
640
641 to standard output upon completion, unless the -s
642 option is specified. The current line number is
643 unchanged.
644
645
646 (.+1)<new-line> An address alone on a line causes the addressed line
647 to be written. A new-line alone is equivalent to
648 .+1p. It is useful for stepping forward through the
649 buffer. The current line number will be set to the
650 address of the written line.
651
652
653
654 If an interrupt signal (ASCII DEL or BREAK) is sent, ed writes a "?\n"
655 and returns to its command level.
656
657
658 The ed utility takes the standard action for all signals with the fol‐
659 lowing exceptions:
660
661 SIGINT The ed utility interrupts its current activity, writes the
662 string "?\n" to standard output, and returns to command mode.
663
664
665 SIGHUP If the buffer is not empty and has changed since the last
666 write, the ed utility attempts to write a copy of the buffer
667 in a file. First, the file named ed.hup in the current direc‐
668 tory is used. If that fails, the file named ed.hup in the
669 directory named by the HOME environment variable is used. In
670 any case, the ed utility exits without returning to command
671 mode.
672
673
674
675 Some size limitations are in effect: 512 characters in a line, 256
676 characters in a global command list, and 255 characters in the path
677 name of a file (counting slashes). The limit on the number of lines
678 depends on the amount of user memory. Each line takes 1 word.
679
680
681 When reading a file, ed discards ASCII and NUL characters.
682
683
684 If a file is not terminated by a new-line character, ed adds one and
685 puts out a message explaining what it did.
686
687
688 If the closing delimiter of an RE or of a replacement string (for exam‐
689 ple, /) would be the last character before a new-line, that delimiter
690 may be omitted, in which case the addressed line is written. The fol‐
691 lowing pairs of commands are equivalent:
692
693 s/s1/s2 s/s1/s2/p
694
695
696 g/s1 g/s1/p
697
698
699 ?s1 ?s1?
700
701
702
703 If an invalid command is entered, ed writes the string:
704
705
706 "?\n"
707
708
709 (followed by an explanatory message if help mode has been enabled by
710 the H command) to standard output and continues in command mode with
711 the current line number unchanged.
712
714 -C Encryption option. The same as the -x option, except that
715 ed simulates a C command. The C command is like the X com‐
716 mand, except that all text read in is assumed to have been
717 encrypted.
718
719
720 -pstring Allows the user to specify a prompt string. By default,
721 there is no prompt string.
722
723
724 -s | -; Suppresses the writing of character counts by e, r, and w
725 commands, of diagnostics from e and q commands, and of the
726 ! prompt after a !shell command.
727
728
729 -x Encryption option. When -x is used, ed simulates an X com‐
730 mand and prompts the user for a key. The X command makes
731 an educated guess to determine whether text read in is
732 encrypted or not. The temporary buffer file is encrypted
733 also, using a transformed version of the key typed in for
734 the -x option. See NOTES.
735
736
738 The following operand is supported:
739
740 file If file is specified, ed simulates an e command on the file
741 named by the path name file before accepting commands from the
742 standard input.
743
744
746 See largefile(5) for the description of the behavior of ed and red when
747 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
748
750 See environ(5) for descriptions of the following environment variables
751 that affect the execution of ed: HOME, LANG, LC_ALL, LC_CTYPE, LC_COL‐
752 LATE, LC_MESSAGES, and NLSPATH.
753
755 The following exit values are returned:
756
757 0 Successful completion without any file or command errors.
758
759
760 >0 An error occurred.
761
762
764 $TMPDIR If this environment variable is not NULL, its value is used
765 in place of /var/tmp as the directory name for the tempo‐
766 rary work file.
767
768
769 /var/tmp If /var/tmp exists, it is used as the directory name for
770 the temporary work file.
771
772
773 /tmp If the environment variable TMPDIR does not exist or is
774 NULL, and if /var/tmp does not exist, then /tmp is used as
775 the directory name for the temporary work file.
776
777
778 ed.hup Work is saved here if the terminal is hung up.
779
780
782 See attributes(5) for descriptions of the following attributes:
783
784 /usr/bin/ed, /usr/bin/red
785 ┌─────────────────────────────┬─────────────────────────────┐
786 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
787 ├─────────────────────────────┼─────────────────────────────┤
788 │Availability │SUNWcsu │
789 ├─────────────────────────────┼─────────────────────────────┤
790 │CSI │Enabled │
791 └─────────────────────────────┴─────────────────────────────┘
792
793 /usr/xpg4/bin/ed
794 ┌─────────────────────────────┬─────────────────────────────┐
795 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
796 ├─────────────────────────────┼─────────────────────────────┤
797 │Availability │SUNWxcu4 │
798 ├─────────────────────────────┼─────────────────────────────┤
799 │CSI │Enabled │
800 ├─────────────────────────────┼─────────────────────────────┤
801 │Interface Stability │Standard │
802 └─────────────────────────────┴─────────────────────────────┘
803
804 /usr/xpg6/bin/ed
805 ┌─────────────────────────────┬─────────────────────────────┐
806 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
807 ├─────────────────────────────┼─────────────────────────────┤
808 │Availability │SUNWxcu6 │
809 ├─────────────────────────────┼─────────────────────────────┤
810 │CSI │Enabled │
811 ├─────────────────────────────┼─────────────────────────────┤
812 │Interface Stability │Standard │
813 └─────────────────────────────┴─────────────────────────────┘
814
816 bfs(1), edit(1), ex(1), grep(1), ksh(1), sed(1), sh(1), stty(1),
817 umask(1), vi(1), fspec(4), attributes(5), environ(5), largefile(5),
818 regex(5), standards(5)
819
821 ? for command errors.
822
823
824 ?file for an inaccessible file. Use the help and Help commands for
825 detailed explanations.
826
827
828
829 If changes have been made in the buffer since the last w command that
830 wrote the entire buffer, ed warns the user if an attempt is made to
831 destroy ed's buffer via the e or q commands. It writes ? and allows one
832 to continue editing. A second e or q command at this point will take
833 effect. The -s command-line option inhibits this feature.
834
836 The - option, although it continues to be supported, has been replaced
837 in the documentation by the -s option that follows the Command Syntax
838 Standard (see Intro(1)).
839
840
841 A ! command cannot be subject to a g or a v command.
842
843
844 The ! command and the ! escape from the e, r, and w commands cannot be
845 used if the editor is invoked from a restricted shell (see sh(1)).
846
847
848 The sequence \n in an RE does not match a new-line character.
849
850
851 If the editor input is coming from a command file (for example, ed file
852 < ed_cmd_file), the editor exits at the first failure.
853
854
855 Loading an alternate malloc() library using the environment variable
856 LD_PRELOAD can cause problems for /usr/bin/ed.
857
858
859
860SunOS 5.11 10 Dec 2003 ed(1)