home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / utility / sed / sed.man < prev    next >
Encoding:
Text File  |  1989-03-06  |  9.1 KB  |  122 lines

  1. NAME
  2.    sed - the stream editor
  3.  
  4.  
  5. SYNOPSIS
  6.    sed [-n] [-g] [-e script ] [-f sfile ] [ file ] ...
  7.  
  8.  
  9. DESCRIPTION
  10.    Sed copies the named files (standard input default) to the standard
  11. output, edited according to a script of commands. 
  12.    An -e option supplies a single edit command from the next argument;
  13. if there are several of these they are executed in the order in  which
  14. they appear. If there is just one -e option and no -f 's, the -e  flag
  15. may be omitted.
  16.    An -f option causes commands to be taken from the file "sfile";  if
  17. there are several  of these they are  executed in the order  in  which
  18. they appear; -e and -f commands may be mixed.
  19.    The -g option causes sed to act as though every substitute  command
  20. in the script has a g suffix.
  21.    The -n option suppresses the default output.
  22.  
  23.    A script consists of commands, one per line, of the following form:
  24.  
  25. [address [, address] ] function [arguments]
  26.  
  27.    Normally sed cyclically copies a line of input into a  current text
  28. buffer, then applies all commands whose addresses select the buffer in
  29. sequence, then copies the buffer to standard output and clears it.
  30.    The -n option suppresses normal output (so that only p and w output
  31. is done). Also, some commands (n, N) do their own line reads, and some
  32. others (d, D) cause all commands following in the script to be skipped
  33. (the D command also suppresses the clearing of the current text buffer
  34. that would normally occur before the next cycle).
  35.  
  36.    It is also helpful to know that there's a second buffer (called the
  37. 'hold space' that can be copied or appended to or from or swapped with
  38. the current text buffer.
  39.  
  40.    An address is: a decimal numeral (which matches the line it numbers
  41. where line numbers start at 1 and run cumulatively across files), or a
  42. `$' that addresses the last line of input, or a context address, which
  43. is a `/regular expression/', in the style of ed (1) modified thus:
  44.  
  45. (1) The escape sequence `\n'  matches a newline embedded in the buffer,
  46.     and `\t' matches a tab.
  47.  
  48. (2) A command line with no addresses selects every buffer.
  49.  
  50. (3) A command line with one address selects every buffer that  matches
  51.     that address.
  52.  
  53. (4) A command line with two addresses selects the inclusive range from
  54.     the first input buffer  that matches the first address through the
  55.     next input buffer  that matches the second. (If the second address
  56.     is a number less than or equal to the line number first  selected,
  57.     only one line is selected.) Once the second address is matched sed
  58.     starts looking for the first one again; thus,  any number of these 
  59.     ranges will be matched.
  60.  
  61.    The negation operator '!' can prefix a command to apply it to every
  62. line not selected by the address(es).
  63.  
  64.    In the following list of functions, the maximum number of addresses
  65. permitted for each function is indicated in parentheses.
  66.    An argument denoted "text" consists of one or more lines,  with all
  67. but the last ending with `\' to hide the newline.
  68.    Backslashes in text are treated like backslashes i`נüâêOäê◆üÄ ✓✓ü≡ä⇧äéêOÇ✓נÄנÅäHOîë/* in an address range? */
  69.         } flags;
  70. };
  71. typedef struct cmd_t    sedcmd;         /* use this name for declarations */
  72.  
  73. #define BAD     ((char *) -1)           /* guaranteed not a string ptr */
  74.  
  75.  
  76. /* address and regular expression compiled-form markers */
  77. #define STAR    1       /* marker for Kleene star */
  78. #define CCHR    2       /* non-newline character to be matched follows */
  79. #define CDOT    4       /* dot wild-card marker */
  80. #define CCL     6       /* character class follows */
  81. #define CNL     8       /* match line start */
  82. #define CDOL    10      /* match line end */
  83. #define CBRA    12      /* tagged pattern start marker */
  84. #define CKET    14      /* tagged pattern end marker */
  85. #define CBACK   16      /* backslash-digit pair marker */
  86. #define CLNUM   18      /* numeric-address index follows */
  87. #define CEND    20      /* symbol for end-of-source */
  88. #define CEOF    22      /* end-of-field mark */
  89.  
  90. /* sed.h ends here */
  91. filename.
  92.    * The g, p and P options on s commands may be given in any order.
  93.  
  94. Some enhancements to regular-expression syntax have been made:
  95.    * \t is recognized in REs (and elswhere) as an escape for tab.
  96.    * In an RE, + calls for 1..n repeats of the previous pattern.
  97.  
  98. The following are completely new features:
  99.    * The l command (list, undocumented and weaker in BSD)
  100.    * The W command (write first line of pattern space to file).
  101.    * The T command (branch on last substitute failed).
  102.    * Trailing comments are now allowed on command lines.
  103.  
  104.    In addition,  sed's error messages have been made more specific and
  105. informative.
  106.  
  107.    The implementation is also  significantly  smaller and  faster than 
  108. BSD 4.1 sed. It uses only the standard I/O library and exit.
  109.  
  110.  
  111. NOTE
  112.    This is a freeware component of the GNU  operating system. The user
  113. is hereby granted permission to use, modify, reproduce and  distribute
  114. it subject to the following conditions:
  115.    1. The authorship notice appearing  in  each source file may not be
  116. altered or deleted.
  117.    2. The object form may not be distributed without source.
  118.  
  119.  
  120. SEE ALSO
  121.    ed(1), grep(1), awk(1), lex(1), regexp(5)
  122.