home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / utilities / cli / gnuinfo / etc / info / Ed < prev    next >
Encoding:
GNU Info File  |  1994-09-14  |  23.4 KB  |  633 lines

  1. This is Info file ed.info, produced by Makeinfo-1.55 from the input
  2. file ed.texinfo.
  3.  
  4.    This file documents the `ed' command, which has the purpose of
  5. editing text files.
  6.  
  7.    Copyright (C) 1993 by the Free Software Foundation, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.  
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that this permission notice may be stated in a
  21. translation approved by the Foundation.
  22.  
  23. 
  24. File: ed.info,  Node: Top,  Next: Description,  Prev: (dir),  Up: (dir)
  25.  
  26.  
  27.  
  28.    This file documents the `ed' command, as of release 0.1.  You may
  29. find in this document:
  30.  
  31. * Menu:
  32.  
  33. * Description::                 Description
  34. * Invoking::                    Invoking GNU `ed'
  35. * Line addressing::             Line addressing
  36. * Regular expressions::         Regular expressions
  37. * Commands::                    Commands
  38. * Limitations::                 Limitations
  39. * Diagnostics::                 Diagnostics
  40.  
  41. 
  42. File: ed.info,  Node: Description,  Next: Invoking,  Prev: Top,  Up: Top
  43.  
  44. Description
  45. ***********
  46.  
  47.    `ed' is a line-oriented text editor.  It is used to create, display,
  48. modify and otherwise manipulate text files.  `red' is a restricted
  49. `ed': it can only edit files in the current directory and cannot
  50. execute shell commands.
  51.  
  52.    Related programs or routines are `vi (1)', `sed (1)', `regex (3)',
  53. `bdes (1)' and `sh (1)'.  Related documents are `USD:12-13' and:
  54.  
  55.      B. W. Kernighan and P. J. Plauger: "Software Tools in Pascal",
  56.      Addison-Wesley, 1981.
  57.  
  58.    If invoked with a FILE argument, then a copy of FILE is read into
  59. the editor's buffer.  Changes are made to this copy and not directly to
  60. FILE itself.  Upon quitting `ed', any changes not explicitly saved with
  61. a `w' command are lost.
  62.  
  63.    Editing is done in two distinct modes: "command" and "input".  When
  64. first invoked, `ed' is in command mode.  In this mode commands are read
  65. from the standard input and executed to manipulate the contents of the
  66. editor buffer.  A typical command might look like:
  67.  
  68.      ,s/OLD/NEW/g
  69.  
  70. which replaces all occurences of the string OLD with NEW.
  71.  
  72.    When an input command, such as `a' (append), `i' (insert) or `c'
  73. (change), is given, `ed' enters input mode.  This is the primary means
  74. of adding text to a file.  In this mode, no commands are available;
  75. instead, the standard input is written directly to the editor buffer.
  76. The text up to and including a newline character defines a single line.
  77. Input mode is terminated by entering a single period (`.') on a line.
  78.  
  79.    All `ed' commands operate on whole lines or ranges of lines; e.g.,
  80. the `d' command deletes lines; the `m' command moves lines, and so on.
  81. It is possible to modify only a portion of a line by means of
  82. replacement, as in the example above.  However even here, the `s'
  83. command is applied to whole lines at a time.
  84.  
  85.    In general, `ed' commands consist of zero or more line addresses,
  86. followed by a single character command and possibly additional
  87. parameters; i.e., commands have the structure:
  88.  
  89.      [ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]
  90.  
  91.    The ADDRESS(es) indicate the line or range of lines to be affected
  92. by the command.  If fewer addresses are given than the command accepts,
  93. then default addresses are supplied.
  94.  
  95. 
  96. File: ed.info,  Node: Invoking,  Next: Line addressing,  Prev: Description,  Up: Top
  97.  
  98. Invoking GNU `ed'
  99. *****************
  100.  
  101.      ed [-] [-Gs] [-p STRING] [FILE]
  102.      red [-] [-Gs] [-p STRING] [FILE]
  103.  
  104. `-G'
  105.      Forces backwards compatibility.  This affects the behavior of the
  106.      `ed' commands `G', `f', `l', `m', `t' and `!!'.  If the default
  107.      behavior of these commands does not seem familiar, then try
  108.      invoking `ed' with this switch.
  109.  
  110. `-s'
  111. `-'
  112.      Suppresses diagnostics. This should be used if `ed''s standard
  113.      input is from a script.
  114.  
  115. `-p STRING'
  116.      Specifies a command prompt.  This may be toggled on and off with
  117.      the `P' command.
  118.  
  119.    FILE specifies the name of a file to read.  If FILE is prefixed with
  120. a bang (!), then it is interpreted as a shell command.  In this case,
  121. what is read is the standard output of FILE executed via `sh (1)'.  To
  122. read a file whose name begins with a bang, prefix the name with a
  123. backslash (`\').  The default filename is set to FILE only if it is not
  124. prefixed with a bang.
  125.  
  126. 
  127. File: ed.info,  Node: Line addressing,  Next: Regular expressions,  Prev: Invoking,  Up: Top
  128.  
  129. Line addressing
  130. ***************
  131.  
  132.    An address represents the number of a line in the buffer.  `ed'
  133. maintains a "current address" which is typically supplied to commands
  134. as the default address when none is specified.  When a file is first
  135. read, the current address is set to the last line of the file.  In
  136. general, the current address is set to the last line affected by a
  137. command.
  138.  
  139.    A line address is constructed from one of the bases in the list
  140. below, optionally followed by a numeric offset.  The offset may include
  141. any combination of digits, operators (i.e., `+', `-' and `^') and
  142. whitespace.  Addresses are read from left to right, and their values
  143. are computed relative to the current address.
  144.  
  145.    One exception to the rule that addresses represent line numbers is
  146. the address `0' (zero).  This means "before the first line," and is
  147. legal wherever it makes sense.
  148.  
  149.    An address range is two addresses separated either by a comma or
  150. semi-colon. The value of the first address in a range cannot exceed the
  151. value of the the second.  If only one address is given in a range, then
  152. the second address is set to the given address.  If an N-tuple of
  153. addresses is given where N > 2, then the corresponding range is
  154. determined by the last two addresses in the N-tuple.  If only one
  155. address is expected, then the last address is used.
  156.  
  157.    Each address in a comma-delimited range is interpreted relative to
  158. the current address.  In a semi-colon-delimited range, the first
  159. address is used to set the current address, and the second address is
  160. interpreted relative to the first.
  161.  
  162.    The following address symbols are recognized.
  163.  
  164. `.'
  165.      The current line (address) in the buffer.
  166.  
  167. `$'
  168.      The last line in the buffer.
  169.  
  170. `N'
  171.      The Nth, line in the buffer where N is a number in the range `0,$'.
  172.  
  173. `-'
  174. `^'
  175.      The previous line.  This is equivalent to `-1' and may be repeated
  176.      with cumulative effect.
  177.  
  178. `-N'
  179. `^N'
  180.      The Nth previous line, where N is a non-negative number.
  181.  
  182. `+'
  183.      The next line.  This is equivalent to `+1' and may be repeated with
  184.      cumulative effect.
  185.  
  186. `+N'
  187. `WHITESPACE N'
  188.      The Nth next line, where N is a non-negative number.  Whitespace
  189.      followed by a number N is interpreted as `+N'.
  190.  
  191. `,'
  192. `%'
  193.      The first through last lines in the buffer.  This is equivalent to
  194.      the address range `1,$'.
  195.  
  196. `;'
  197.      The current through last lines in the buffer.  This is equivalent
  198.      to the address range `.,$'.
  199.  
  200. `/RE/'
  201.      The next line containing the regular expression RE.  The search
  202.      wraps to the beginning of the buffer and continues down to the
  203.      current line, if necessary.  `//' repeats the last search.
  204.  
  205. `?RE?'
  206.      The previous line containing the regular expression RE.  The
  207.      search wraps to the end of the buffer and continues up to the
  208.      current line, if necessary.  `??' repeats the last search.
  209.  
  210. `'LC'
  211.      The line previously marked by a `k' (mark) command, where LC is a
  212.      lower case letter.
  213.  
  214. 
  215. File: ed.info,  Node: Regular expressions,  Next: Commands,  Prev: Line addressing,  Up: Top
  216.  
  217. Regular expressions
  218. *******************
  219.  
  220.    Regular expressions are patterns used in selecting text.  For
  221. example, the `ed' command
  222.  
  223.      g/STRING/
  224.  
  225. prints all lines containing STRING.  Regular expressions are also used
  226. by the `s' command for selecting old text to be replaced with new.
  227.  
  228.    In addition to a specifying string literals, regular expressions can
  229. represent classes of strings.  Strings thus represented are said to be
  230. matched by the corresponding regular expression.  If it is possible for
  231. a regular expression to match several strings in a line, then the
  232. left-most longest match is the one selected.
  233.  
  234.    The following symbols are used in constructing regular expressions:
  235.  
  236. `C'
  237.      Any character C not listed below, including `{', `}', `(', `)',
  238.      `<' and `>', matches itself.
  239.  
  240. `\C'
  241.      Any backslash-escaped character C, except for `{', ``}', `(', `)',
  242.      `<' and `>', matches itself.
  243.  
  244. `.'
  245.      Matches any single character.
  246.  
  247. `[CHAR-CLASS]'
  248.      Matches any single character in CHAR-CLASS.  To include a `]' in
  249.      CHAR-CLASS, it must be the first character.  A range of characters
  250.      may be specified by separating the end characters of the range
  251.      with a `-', e.g., `a-z' specifies the lower case characters.  The
  252.      following literal expressions can also be used in CHAR-CLASS to
  253.      specify sets of characters:
  254.  
  255.           [:alnum:] [:cntrl:] [:lower:] [:space:]
  256.           [:alpha:] [:digit:] [:print:] [:upper:]
  257.           [:blank:] [:graph:] [:punct:] [:xdigit:]
  258.  
  259.      If `-' appears as the first or last character of CHAR-CLASS, then
  260.      it matches itself.  All other characters in CHAR-CLASS match
  261.      themselves.
  262.  
  263.      Patterns in CHAR-CLASS of the form:
  264.           [.COL-ELM.]
  265.           [=COL-ELM=]
  266.  
  267.      where COL-ELM is a "collating element" are interpreted according
  268.      to `locale (5)' (not currently supported).  See `regex (3)' for an
  269.      explanation of these constructs.
  270.  
  271. `[^CHAR-CLASS]'
  272.      Matches any single character, other than newline, not in
  273.      CHAR-CLASS.  CHAR-CLASS is defined as above.
  274.  
  275. `^'
  276.      If `^' is the first character of a regular expression, then it
  277.      anchors the regular expression to the beginning of a line.
  278.      Otherwise, it matches itself.
  279.  
  280. `$'
  281.      If `$' is the last character of a regular expression, it anchors
  282.      the regular expression to the end of a line.  Otherwise, it matches
  283.      itself.
  284.  
  285. `\<'
  286.      Anchors the single character regular expression or subexpression
  287.      immediately following it to the beginning of a word.  (This may
  288.      not be available)
  289.  
  290. `\>'
  291.      Anchors the single character regular expression or subexpression
  292.      immediately following it to the end of a word.  (This may not be
  293.      available)
  294.  
  295. `\(RE\)'
  296.      Defines a subexpression RE.  Subexpressions may be nested.  A
  297.      subsequent backreference of the form `\N', where N is a number in
  298.      the range [1,9], expands to the text matched by the Nth
  299.      subexpression.  For example, the regular expression `\([ab]\)\1'
  300.      matches the strings `aa' and `bb' (and only these).
  301.      Subexpressions are ordered relative to their left delimiter.
  302.  
  303. `*'
  304.      Matches the single character regular expression or subexpression
  305.      immediately preceding it zero or more times.  If `*' is the first
  306.      character of a regular expression or subexpression, then it matches
  307.      itself.  The `*' operator sometimes yields unexpected results.  For
  308.      example, the regular expression `b*' matches the beginning of the
  309.      string `abbb' (as opposed to the substring `bbb'), since a null
  310.      match is the only left-most match.
  311.  
  312. `{N,M}'
  313. `{N,}'
  314. `{N}'
  315.      Matches the single character regular expression or subexpression
  316.      immediately preceding it at least N and at most M times.  If M is
  317.      omitted, then it matches at least N times.  If the comma is also
  318.      omitted, then it matches exactly N times.
  319.  
  320.    Additional regular expression operators may be defined depending on
  321. the particular `regex (3)' implementation.
  322.  
  323. 
  324. File: ed.info,  Node: Commands,  Next: Limitations,  Prev: Regular expressions,  Up: Top
  325.  
  326. Commands
  327. ********
  328.  
  329.    All `ed' commands are single characters, though some require
  330. additonal parameters.  If a command's parameters extend over several
  331. lines, then each line except for the last must be terminated with a
  332. backslash (`\').
  333.  
  334.    In general, at most one command is allowed per line.  However, most
  335. commands accept a print suffix, which is any of `p' (print), `l'
  336. (list), or `n' (enumerate), to print the last line affected by the
  337. command.
  338.  
  339.    An interrupt (typically ^C) has the effect of aborting the current
  340. command and returning the editor to command mode.
  341.  
  342.    `ed' recognizes the following commands.  The commands are shown
  343. together with the default address or address range supplied if none is
  344. specified (in parenthesis).
  345.  
  346. `(.)a'
  347.      Appends text to the buffer after the addressed line.  Text is
  348.      entered in input mode.  The current address is set to last line
  349.      entered.
  350.  
  351. `(.,.)c'
  352.      Changes lines in the buffer.  The addressed lines are deleted from
  353.      the buffer, and text is appended in their place.  Text is entered
  354.      in input mode.  The current address is set to last line entered.
  355.  
  356. `(.,.)d'
  357.      Deletes the addressed lines from the buffer.  If there is a line
  358.      after the deleted range, then the current address is set to this
  359.      line.  Otherwise the current address is set to the line before the
  360.      deleted range.
  361.  
  362. `e FILE'
  363.      Edits FILE, and sets the default filename.  If FILE is not
  364.      specified, then the default filename is used.  Any lines in the
  365.      buffer are deleted before the new file is read.  The current
  366.      address is set to the last line read.
  367.  
  368. `e !COMMAND'
  369.      Edits the standard output of `!COMMAND', (see `!' command below).
  370.      The default filename is unchanged.  Any lines in the buffer are
  371.      deleted before the output of COMMAND is read.  The current address
  372.      is set to the last line read.
  373.  
  374. `E FILE'
  375.      Edits FILE unconditionally.  This is similar to the `e' command,
  376.      except that unwritten changes are discarded without warning.  The
  377.      current address is set to the last line read.
  378.  
  379. `f FILE'
  380.      Sets the default filename to FILE.  If FILE is not specified, then
  381.      the default unescaped filename is printed.
  382.  
  383. `(1,$)g /RE/COMMAND-LIST'
  384.      Applies COMMAND-LIST to each of the addressed lines matching a
  385.      regular expression RE.  The current address is set to the line
  386.      currently matched before COMMAND-LIST is executed.  At the end of
  387.      the `g' command, the current address is set to the last line
  388.      affected by COMMAND-LIST.
  389.  
  390.      Each command in COMMAND-LIST must be on a separate line, and every
  391.      line except for the last must be terminated by a backslash (`\').
  392.      Any commands are allowed, except for `g', `G', `v', and `V'.  A
  393.      newline alone in COMMAND-LIST is equivalent to a `p' command.
  394.  
  395. `(1,$)G /RE/'
  396.      Interactively edits the addressed lines matching a regular
  397.      expression RE.  For each matching line, the line is printed, the
  398.      current address is set, and the user is prompted to enter a
  399.      COMMAND-LIST.  At the end of the `G' command, the current address
  400.      is set to the last line affected by (the last) COMMAND-LIST.
  401.  
  402.      The format of COMMAND-LIST is the same as that of the `g' command.
  403.      A newline alone acts as a null command list.  A single `&'
  404.      repeats the last non-null command list.
  405.  
  406. `H'
  407.      Toggles the printing of error explanations.  By default,
  408.      explanations are not printed.  It is recommended that ed scripts
  409.      begin with this command to aid in debugging.
  410.  
  411. `h'
  412.      Prints an explanation of the last error.
  413.  
  414. `(.)i'
  415.      Inserts text in the buffer before the current line.  Text is
  416.      entered in input mode.  The current address is set to the last
  417.      line entered.
  418.  
  419. `(.,.+1)j'
  420.      Joins the addressed lines.  The addressed lines are deleted from
  421.      the buffer and replaced by a single line containing their joined
  422.      text.  The current address is set to the resultant line.
  423.  
  424. `(.)k LC'
  425.      Marks a line with a lower case letter LC.  The line can then be
  426.      addressed as `'LC' (i.e., a single quote followed by LC) in
  427.      subsequent commands.  The mark is not cleared until the line is
  428.      deleted or otherwise modified.
  429.  
  430. `(.,.)l'
  431.      Prints the addressed lines unambiguously.  If a single line fills
  432.      for than one screen (as might be the case when viewing a binary
  433.      file, for instance), a `--More--' prompt is printed on the last
  434.      line.  `ed' waits until the RETURN key is pressed before displaying
  435.      the next screen.  The current address is set to the last line
  436.      printed.
  437.  
  438. `(.,.)m(.)'
  439.      Moves lines in the buffer.  The addressed lines are moved to after
  440.      the right-hand destination address, which may be the address `0'
  441.      (zero).  The current address is set to the last line moved.
  442.  
  443. `(.,.)n'
  444.      Prints the addressed lines along with their line numbers.  The
  445.      current address is set to the last line printed.
  446.  
  447. `(.,.)p'
  448.      Prints the addressed lines. The current address is set to the last
  449.      line printed.
  450.  
  451. `P'
  452.      Toggles the command prompt on and off.  Unless a prompt was
  453.      specified by with command-line option `-p STRING', the command
  454.      prompt is by default turned off.
  455.  
  456. `q'
  457.      Quits `ed'.
  458.  
  459. `Q'
  460.      Quits `ed' unconditionally.  This is similar to the `q' command,
  461.      except that unwritten changes are discarded without warning.
  462.  
  463. `($)r FILE'
  464.      Reads FILE to after the addressed line.  If FILE is not specified,
  465.      then the default filename is used.  If there was no default
  466.      filename prior to the command, then the default filename is set to
  467.      FILE.  Otherwise, the default filename is unchanged.  The current
  468.      address is set to the last line read.
  469.  
  470. `($)r !COMMAND'
  471.      Reads to after the addressed line the standard output of
  472.      `!command', (see the `!' command below).  The default filename is
  473.      unchanged.  The current address is set to the last line read.
  474.  
  475. `(.,.)s /RE/REPLACEMENT/'
  476. `(.,.)s /RE/REPLACEMENT/g'
  477. `(.,.)s /RE/REPLACEMENT/n'
  478.      Replaces text in the addressed lines matching a regular expression
  479.      RE with REPLACEMENT.  By default, only the first match in each
  480.      line is replaced.  If the `g' (global) suffix is given, then every
  481.      match to be replaced.  The `n' suffix, where N is a postive
  482.      number, causes only the Nth match to be replaced.  It is an error
  483.      if no substitutions are performed on any of the addressed lines.
  484.      The current address is set the last line affected.
  485.  
  486.      RE and REPLACEMENT may be delimited by any character other than
  487.      space and newline (see the `s' command below).  If one or two of
  488.      the last delimiters is omitted, then the last line affected is
  489.      printed as though the print suffix `p' were specified.
  490.  
  491.      An unescaped `&' in REPLACEMENT is replaced by the currently
  492.      matched text.  The character sequence `\M' where M is a number in
  493.      the range [1,9], is replaced by the Mth backreference expression
  494.      of the matched text.  If REPLACEMENT consists of a single `%',
  495.      then REPLACEMENT from the last substitution is used.  Newlines may
  496.      be embedded in REPLACEMENT if they are escaped with a backslash
  497.      (`\').
  498.  
  499. `(.,.)s'
  500.      Repeats the last substitution.  This form of the `s' command
  501.      accepts a count suffix N, or any combination of the characters
  502.      `r', `g', and `p'.  If a count suffix N is given, then only the
  503.      Nth match is replaced.  The `r' suffix causes the regular
  504.      expression of the last search to be used instead of the that of
  505.      the last substitution.  The `g' suffix toggles the global suffix
  506.      of the last substitution.  The `p' suffix toggles the print suffix
  507.      of the last substitution The current address is set to the last
  508.      line affected.
  509.  
  510. `(.,.)t(.)'
  511.      Copies (i.e., transfers) the addressed lines to after the
  512.      right-hand destination address, which may be the address `0'
  513.      (zero).  The current address is set to the last line copied.
  514.  
  515. `u'
  516.      Undoes the last command and restores the current address to what
  517.      it was before the command.  The global commands `g', `G', `v', and
  518.      `V' are treated as a single command by undo.  `u' is its own
  519.      inverse.
  520.  
  521. `(1,$)v /PAT/COMMAND-LIST'
  522.      Applies COMMAND-LIST to each of the addressed lines not matching a
  523.      regular expression RE.  This is similar to the `g' command.
  524.  
  525. `(1,$)V /RE/'
  526.      Interactively edits the addressed lines not matching a regular
  527.      expression RE.  This is similar to the `G' command.
  528.  
  529. `(1,$)w FILE'
  530.      Writes the addressed lines to FILE.  Any previous contents of FILE
  531.      is lost without warning.  If there is no default filename, then
  532.      the default filename is set to FILE, otherwise it is unchanged.
  533.      If no filename is specified, then the default filename is used.
  534.      The current address is unchanged.
  535.  
  536. `(1,$)wq FILE'
  537.      Writes the addressed lines to FILE, and then executes a `q'
  538.      command.
  539.  
  540. `(1,$)w !COMMAND'
  541.      Writes the addressed lines to the standard input of `!COMMAND',
  542.      (see the `!' command below).  The default filename and current
  543.      address are unchanged.
  544.  
  545. `(1,$)W FILE'
  546.      Appends the addressed lines to the end of FILE.  This is similar
  547.      to the `w' command, expect that the previous contents of file is
  548.      not clobbered.  The current address is unchanged.
  549.  
  550. `(.+1)z N'
  551.      Scrolls N lines at a time starting at addressed line.  If N is not
  552.      specified, then the current window size is used.  The current
  553.      address is set to the last line printed.
  554.  
  555. `! COMMAND'
  556.      Executes COMMAND via `sh (1)'.  If the first character of COMMAND
  557.      is `!', then it is replaced by text of the previous `!COMMAND'.
  558.      `ed' does not process COMMAND for backslash (`\') escapes.
  559.      However, an unescaped `%' is replaced by the default filename.
  560.      When the shell returns from execution, a `!' is printed to the
  561.      standard output.  The current line is unchanged.
  562.  
  563. `(.,.)#'
  564.      Begins a comment;  the rest of the line, up to a newline, is
  565.      ignored.  If a line address followed by a semi-colon is given,
  566.      then the current address is set to that address.  Otherwise, the
  567.      current address is unchanged.
  568.  
  569. `($)='
  570.      Prints the line number of the addressed line.
  571.  
  572. `(.+1)newline'
  573.      Prints the addressed line, and sets the current address to that
  574.      line.
  575.  
  576. 
  577. File: ed.info,  Node: Limitations,  Next: Diagnostics,  Prev: Commands,  Up: Top
  578.  
  579. Limitations
  580. ***********
  581.  
  582.    The buffer files are kept in `/tmp/ed.*'.  If the terminal hangs up,
  583. `ed' attempts to write the buffer to file `ed.hup'.
  584.  
  585.    `ed' processes FILE arguments for backslash escapes, i.e., in a
  586. filename, any characters preceded by a backslash (`\') are interpreted
  587. literally.
  588.  
  589.    If a text (non-binary) file is not terminated by a newline character,
  590. then `ed' appends one on reading/writing it.  In the case of a binary
  591. file, `ed' does not append a newline on reading/writing.
  592.  
  593.    Per line overhead: 4 `int's.
  594.  
  595. 
  596. File: ed.info,  Node: Diagnostics,  Prev: Limitations,  Up: Top
  597.  
  598. Diagnostics
  599. ***********
  600.  
  601.    When an error occurs, `ed' prints a `?' and either returns to
  602. command mode or exits if its input is from a script.  An explanation of
  603. the last error can be printed with the `h' (help) command.
  604.  
  605.    Since the `g' (global) command  masks any errors from failed
  606. searches and substitutions, it can be used to perform conditional
  607. operations in scripts; e.g.,
  608.  
  609.      g/OLD/s//NEW/
  610.  
  611. replaces any occurrences of OLD with NEW.  If the `u' (undo) command
  612. occurs in a global command list, then the command list is executed only
  613. once.
  614.  
  615.    If diagnostics are not disabled, attempting to quit `ed' or edit
  616. another file before writing a modified buffer results in an error.  If
  617. the command is entered a second time, it succeeds, but any changes to
  618. the buffer are lost.
  619.  
  620.  
  621. 
  622. Tag Table:
  623. Node: Top894
  624. Node: Description1397
  625. Node: Invoking3682
  626. Node: Line addressing4717
  627. Node: Regular expressions7772
  628. Node: Commands11849
  629. Node: Limitations22271
  630. Node: Diagnostics22889
  631. 
  632. End Tag Table
  633.