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