|
|
1.1 ! root 1: ! 2: ! 3: sed Command sed ! 4: ! 5: ! 6: ! 7: ! 8: Stream editor ! 9: ! 10: sseedd [ -nn ] [-ee _c_o_m_m_a_n_d_s] [-ff _s_c_r_i_p_t] ... _f_i_l_e ... ! 11: ! 12: sed is a non-interactive text editor. It reads input from each ! 13: file, or from the standard input if no file is named. It edits ! 14: the input according to commands given in the commands argument ! 15: and the script files. It then writes the edited text onto the ! 16: standard output. ! 17: ! 18: sed resembles the interactive editor ed, but its operation is ! 19: fundamentally different. sed normally edits one line at a time, ! 20: so it may be used to edit very large files. After it constructs ! 21: a list of commands from its commands and script arguments, sed ! 22: reads the input one line at a time into a work area. Then sed ! 23: executes each command that applies to the line, as explained ! 24: below. Finally, it copies the work area to the standard output ! 25: (unless the -n option is specified), erases the work area, and ! 26: reads the next input line. ! 27: ! 28: ***** Line Identifiers ***** ! 29: ! 30: sed identifies input lines by integer line numbers, beginning ! 31: with one for the first line of the first file and continuing ! 32: through each successive file. The following special forms iden- ! 33: tify lines: ! 34: ! 35: nn A decimal number n addresses the nth line of the input. ! 36: ! 37: . A period `.' addresses the current input line. ! 38: ! 39: $ A dollar sign `$' addresses the last line of input. ! 40: ! 41: /ppaatttteerrnn/ ! 42: A pattern enclosed within slashes addresses the next input ! 43: line that contains pattern. Patterns, also called regular ! 44: expressions, are described in detail below. ! 45: ! 46: ***** Commands ***** ! 47: ! 48: Each command must be on a separate line. Most commands may be ! 49: optionally preceded by a line identifier (abbreviated as [n] in ! 50: the command summary below) or by two-line identifiers separated ! 51: by a comma (abbreviated as [n[,m]]). If no line identifier ! 52: precedes a command, sed applies the command to every input line. ! 53: If one line identifier precedes a command, sed applies the com- ! 54: mand to each input line selected by the identifier. If two-line ! 55: identifiers precede a command, sed begins to apply the command ! 56: when an input line is selected by the first, and continues ap- ! 57: plying it through an input line selected by the second. ! 58: ! 59: sed recognizes the following commands: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66: ! 67: ! 68: ! 69: sed Command sed ! 70: ! 71: ! 72: ! 73: [_n]= Output the current input line number. ! 74: ! 75: [_n[,_m]]!_c_o_m_m_a_n_d ! 76: Apply command to each line not identified by [n[,m]]. ! 77: ! 78: [_n[,_m]]{_c_o_m_m_a_n_d...} ! 79: Execute each enclosed command on the given lines. ! 80: ! 81: :_l_a_b_e_l ! 82: Define label for use in branch or test command. ! 83: ! 84: [_n]aa\ ! 85: Append new text after given line. New text is terminated by ! 86: any line not ending in `\'. ! 87: ! 88: bb [_l_a_b_e_l] ! 89: Branch to label, which must be defined in a `:' command. If ! 90: label is omitted, branch to end of command script. ! 91: ! 92: [_n[,_m]]cc\ ! 93: Change specified lines to new text and proceed with next in- ! 94: put line. New text is terminated by any line not ending in ! 95: `\'. ! 96: ! 97: [_n[,_m]]dd ! 98: Delete specified lines and proceed with next input line. ! 99: ! 100: [_n[,_m]]DD ! 101: Delete first line in work area and proceed with next input ! 102: line. ! 103: ! 104: [_n[,_m]]gg ! 105: Copy secondary work area to work area, destroying previous ! 106: contents. ! 107: ! 108: [_n[,_m]]GG ! 109: Append secondary work area to work area. ! 110: ! 111: [_n[,_m]]hh ! 112: Copy work area to secondary work area, destroying previous ! 113: contents. ! 114: ! 115: [_n[,_m]]HH ! 116: Append work area to secondary work area. ! 117: ! 118: [_n]ii\ ! 119: Insert new text before given line. New text is terminated ! 120: by any line not ending in `\'. ! 121: ! 122: [_n[,_m]]ll ! 123: Print selected lines, interpreting non-graphic characters. ! 124: ! 125: [_n[,_m]]nn ! 126: Print the work area and replace it with the next input line. ! 127: ! 128: ! 129: ! 130: COHERENT Lexicon Page 2 ! 131: ! 132: ! 133: ! 134: ! 135: sed Command sed ! 136: ! 137: ! 138: ! 139: [_n[,_m]]NN ! 140: Append next input line preceded by a newline to work area. ! 141: ! 142: [_n[,_m]]pp ! 143: Print work area. ! 144: ! 145: [_n[,_m]]PP ! 146: Print first line of work area. ! 147: ! 148: [_n]qq Quit without reading any more input. ! 149: ! 150: [_n]rr _f_i_l_e ! 151: Copy file to output. ! 152: ! 153: [_n[,_m]]ss[_k]/_p_a_t_t_e_r_n_1/_p_a_t_t_e_r_n_2/[gg][pp][ww _f_i_l_e] ! 154: Search for pattern1 and substitute pattern2 for kth occur- ! 155: rence (default, first). If optional g is given, substitute ! 156: all occurrences. If optional p is given, print the resul- ! 157: ting line. If optional w is given, append the resulting ! 158: line to file. Patterns are described in detail below. ! 159: ! 160: [_n[,_m]]tt[_l_a_b_e_l] ! 161: Test if substitutions have been made. If so, branch to ! 162: label, which must be defined in a `:' command. If label is ! 163: omitted, branch to end of command script. ! 164: ! 165: [_n[,_m]]ww _f_i_l_e ! 166: Append lines to file. ! 167: ! 168: [_n[,_m]] xx ! 169: Exchange the work area and the secondary work area. ! 170: ! 171: [_n[,_m]]yy/_c_h_a_r_s/_r_e_p_l_a_c_e_m_e_n_t_s/ ! 172: Translate characters in chars to the corresponding charac- ! 173: ters in replacements. ! 174: ! 175: ***** Patterns ***** ! 176: ! 177: Substitution commands and search specifications may include pat- ! 178: terns, also called regular expressions. Pattern specifications ! 179: are identical to those of ed, except that the special characters ! 180: `\nn' match a newline character in the input. ! 181: ! 182: A non-special character in a pattern matches itself. Special ! 183: characters include the following: ! 184: ! 185: ^ Match beginning of line, unless it appears immediately after ! 186: `[' (see below). ! 187: ! 188: $ Match end of line. ! 189: ! 190: \nn Match the newline character. ! 191: ! 192: . Match any character except newline. ! 193: ! 194: ! 195: ! 196: COHERENT Lexicon Page 3 ! 197: ! 198: ! 199: ! 200: ! 201: sed Command sed ! 202: ! 203: ! 204: ! 205: * Match zero or more repetitions of preceding character. ! 206: ! 207: [_c_h_a_r_s] ! 208: Match any one of the enclosed chars. Ranges of letters or ! 209: digits may be indicated using `-'. ! 210: ! 211: [^_c_h_a_r_s] ! 212: Match any character except one of the enclosed chars. Ran- ! 213: ges of letters or digits may be indicated using `-'. ! 214: ! 215: \_c Disregard special meaning of character c. ! 216: ! 217: \(_p_a_t_t_e_r_n\) ! 218: Delimit substring pattern; for use with \_d, described below. ! 219: ! 220: In addition, the replacement part pattern2 of the substitute com- ! 221: mand may also use the following: ! 222: ! 223: & Insert characters matched by pattern1. ! 224: ! 225: \_d Insert substring delimited by dth occurrence of delimiters ! 226: `\(' and `\)', where d is a digit. ! 227: ! 228: ***** Options ***** ! 229: ! 230: sed recognizes the following options: ! 231: ! 232: -ee Next argument gives commands. ! 233: ! 234: -ff Next argument gives file name of command script. ! 235: ! 236: -nn Output lines only when explicit p or P commands are given. ! 237: ! 238: ***** See Also ***** ! 239: ! 240: commands, ed ! 241: ! 242: ! 243: ! 244: ! 245: ! 246: ! 247: ! 248: ! 249: ! 250: ! 251: ! 252: ! 253: ! 254: ! 255: ! 256: ! 257: ! 258: ! 259: ! 260: ! 261: ! 262: COHERENT Lexicon Page 4 ! 263: ! 264:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.