=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sed/sed.1,v retrieving revision 1.7 retrieving revision 1.8 diff -c -r1.7 -r1.8 *** src/usr.bin/sed/sed.1 1999/07/02 20:11:45 1.7 --- src/usr.bin/sed/sed.1 1999/07/04 12:00:04 1.8 *************** *** 1,4 **** ! .\" $OpenBSD: sed.1,v 1.7 1999/07/02 20:11:45 aaron Exp $ .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. .\" --- 1,4 ---- ! .\" $OpenBSD: sed.1,v 1.8 1999/07/04 12:00:04 aaron Exp $ .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. .\" *************** *** 53,59 **** .Op Ar file ... .Sh DESCRIPTION The ! .Nm sed utility reads the specified files, or the standard input if no files are specified, modifying the input as specified by a list of commands. The input is then written to the standard output. --- 53,59 ---- .Op Ar file ... .Sh DESCRIPTION The ! .Nm utility reads the specified files, or the standard input if no files are specified, modifying the input as specified by a list of commands. The input is then written to the standard output. *************** *** 72,86 **** .Bl -tag -width indent .It Fl a The files listed as parameters for the ! .Dq w functions are created (or truncated) before any processing begins, by default. The .Fl a option causes ! .Nm sed to delay opening each file until a command containing the related ! .Dq w function is applied to a line of input. .It Fl e Ar command Append the editing commands specified by the --- 72,86 ---- .Bl -tag -width indent .It Fl a The files listed as parameters for the ! .Ql w functions are created (or truncated) before any processing begins, by default. The .Fl a option causes ! .Nm to delay opening each file until a command containing the related ! .Ql w function is applied to a line of input. .It Fl e Ar command Append the editing commands specified by the *************** *** 101,107 **** .El .Pp The form of a ! .Nm sed command is as follows: .sp .Dl [address[,address]]function[arguments] --- 101,107 ---- .El .Pp The form of a ! .Nm command is as follows: .sp .Dl [address[,address]]function[arguments] *************** *** 110,121 **** portions of the command. .Pp Normally, ! .Nm sed cyclically copies a line of input, not including its terminating newline character, into a .Em "pattern space" , (unless there is something left after a ! .Dq D function), applies all of the commands with addresses that select that pattern space, copies the pattern space to the standard output, appending a newline, and --- 110,121 ---- portions of the command. .Pp Normally, ! .Nm cyclically copies a line of input, not including its terminating newline character, into a .Em "pattern space" , (unless there is something left after a ! .Sq D function), applies all of the commands with addresses that select that pattern space, copies the pattern space to the standard output, appending a newline, and *************** *** 128,136 **** An address is not required, but if specified must be a number (that counts input lines cumulatively across input files), a dollar ! .Po ! .Dq $ ! .Pc character that addresses the last line of input, or a context address (which consists of a regular expression preceded and followed by a delimiter). --- 128,134 ---- An address is not required, but if specified must be a number (that counts input lines cumulatively across input files), a dollar ! .Pq Ql $ character that addresses the last line of input, or a context address (which consists of a regular expression preceded and followed by a delimiter). *************** *** 146,184 **** (If the second address is a number less than or equal to the line number first selected, only that line is selected.) Starting at the first line following the selected range, ! .Nm sed starts looking again for the first address. .Pp Editing commands can be applied to non-selected pattern spaces by use of the exclamation character ! .Po ! .Dq ! ! .Pc function. .Sh "Sed Regular Expressions" The ! .Nm sed regular expressions are basic regular expressions (BRE's, see .Xr regex 3 for more information). In addition, ! .Nm sed has the following two additions to BRE's: .sp .Bl -enum -compact .It In a context address, any character other than a backslash ! .Po ! .Dq \e ! .Pc or newline character may be used to delimit the regular expression. Also, putting a backslash character before the delimiting character causes the character to be treated literally. For example, in the context address \exabc\exdefx, the RE delimiter is an ! .Dq x and the second ! .Dq x stands for itself, so that the regular expression is .Dq abcxdef . .sp --- 144,178 ---- (If the second address is a number less than or equal to the line number first selected, only that line is selected.) Starting at the first line following the selected range, ! .Nm starts looking again for the first address. .Pp Editing commands can be applied to non-selected pattern spaces by use of the exclamation character ! .Pq Ql ! function. .Sh "Sed Regular Expressions" The ! .Nm regular expressions are basic regular expressions (BRE's, see .Xr regex 3 for more information). In addition, ! .Nm has the following two additions to BRE's: .sp .Bl -enum -compact .It In a context address, any character other than a backslash ! .Pq Ql \e or newline character may be used to delimit the regular expression. Also, putting a backslash character before the delimiting character causes the character to be treated literally. For example, in the context address \exabc\exdefx, the RE delimiter is an ! .Sq x and the second ! .Sq x stands for itself, so that the regular expression is .Dq abcxdef . .sp *************** *** 190,196 **** .El .Pp One special feature of ! .Nm sed regular expressions is that they can default to the last regular expression used. If a regular expression is empty, i.e. just the delimiter characters --- 184,190 ---- .El .Pp One special feature of ! .Nm regular expressions is that they can default to the last regular expression used. If a regular expression is empty, i.e. just the delimiter characters *************** *** 217,248 **** taken literally. .Pp The ! .Dq r and ! .Dq w functions take an optional file parameter, which should be separated from the function letter by white space. Each file given as an argument to ! .Nm sed is created (or its contents truncated) before any input processing begins. .Pp The ! .Dq b , ! .Dq r , ! .Dq s , ! .Dq t , ! .Dq w , ! .Dq y , ! .Dq ! , and ! .Dq \&: functions all accept additional arguments. The following synopses indicate which arguments have to be separated from the function letters by white space characters. .Pp Two of the functions take a function-list. This is a list of ! .Nm sed functions separated by newlines, as follows: .Bd -literal -offset indent { function --- 211,242 ---- taken literally. .Pp The ! .Sq r and ! .Sq w functions take an optional file parameter, which should be separated from the function letter by white space. Each file given as an argument to ! .Nm is created (or its contents truncated) before any input processing begins. .Pp The ! .Sq b , ! .Sq r , ! .Sq s , ! .Sq t , ! .Sq w , ! .Sq y , ! .Ql ! , and ! .Ql \&: functions all accept additional arguments. The following synopses indicate which arguments have to be separated from the function letters by white space characters. .Pp Two of the functions take a function-list. This is a list of ! .Nm functions separated by newlines, as follows: .Bd -literal -offset indent { function *************** *** 253,263 **** .Ed .Pp The ! .Dq { can be preceded by white space and can be followed by white space. The function can be preceded by white space. The terminating ! .Dq } must be preceded by a newline or optional white space. .sp .Bl -tag -width "XXXXXX" -compact --- 247,257 ---- .Ed .Pp The ! .Ql { can be preceded by white space and can be followed by white space. The function can be preceded by white space. The terminating ! .Ql } must be preceded by a newline or optional white space. .sp .Bl -tag -width "XXXXXX" -compact *************** *** 271,282 **** .Em text to standard output immediately before each attempt to read a line of input, whether by executing the ! .Dq N function or by beginning a new cycle. .sp .It [2addr]b[label] Branch to the ! .Dq \&: function with the specified label. If the label is not specified, branch to the end of the script. .sp --- 265,276 ---- .Em text to standard output immediately before each attempt to read a line of input, whether by executing the ! .Sq N function or by beginning a new cycle. .sp .It [2addr]b[label] Branch to the ! .Sq \&: function with the specified label. If the label is not specified, branch to the end of the script. .sp *************** *** 347,353 **** Long lines are folded, with the point of folding indicated by displaying a backslash followed by a newline. The end of each line is marked with a ! .Dq $ . .sp .It [2addr]n Write the pattern space to the standard output if the default output has --- 341,347 ---- Long lines are folded, with the point of folding indicated by displaying a backslash followed by a newline. The end of each line is marked with a ! .Ql $ . .sp .It [2addr]n Write the pattern space to the standard output if the default output has *************** *** 389,405 **** a literal character if it is preceded by a backslash. .Pp An ampersand ! .Po ! .Dq & ! .Pc appearing in the replacement is replaced by the string matching the RE. The special meaning of ! .Dq & in this context can be suppressed by preceding it by a backslash. The string ! .Dq \e# , where ! .Dq # is a digit, is replaced by the text matched by the corresponding backreference expression (see .Xr re_format 7 ). --- 383,397 ---- a literal character if it is preceded by a backslash. .Pp An ampersand ! .Pq Ql & appearing in the replacement is replaced by the string matching the RE. The special meaning of ! .Ql & in this context can be suppressed by preceding it by a backslash. The string ! .Ql \e# , where ! .Ql # is a digit, is replaced by the text matched by the corresponding backreference expression (see .Xr re_format 7 ). *************** *** 432,441 **** .sp .It [2addr]t [label] Branch to the ! .Dq \&: function bearing the label if any substitutions have been made since the most recent reading of an input line or execution of a ! .Dq t function. If no label is specified, branch to the end of the script. .sp --- 424,433 ---- .sp .It [2addr]t [label] Branch to the ! .Ql \&: function bearing the label if any substitutions have been made since the most recent reading of an input line or execution of a ! .Sq t function. If no label is specified, branch to the end of the script. .sp *************** *** 458,465 **** and .Em string2 , a backslash followed by any character other than a newline is that literal ! character, and a backslash followed by an ``n'' is replaced by a newline ! character. .sp .It [2addr]!function .It [2addr]!function-list --- 450,458 ---- and .Em string2 , a backslash followed by any character other than a newline is that literal ! character, and a backslash followed by an ! .Sq n ! is replaced by a newline character. .sp .It [2addr]!function .It [2addr]!function-list *************** *** 469,477 **** .sp .It [0addr]:label This function does nothing; it bears a label to which the ! .Dq b and ! .Dq t commands may branch. .sp .It [1addr]= --- 462,470 ---- .sp .It [0addr]:label This function does nothing; it bears a label to which the ! .Sq b and ! .Sq t commands may branch. .sp .It [1addr]= *************** *** 483,492 **** .sp .It [0addr]# The ! .Dq # and the remainder of the line are ignored (treated as a comment), with the single exception that if the first two characters in the file are ! .Dq #n , the default output is suppressed. This is the same as specifying the .Fl n --- 476,485 ---- .sp .It [0addr]# The ! .Ql # and the remainder of the line are ignored (treated as a comment), with the single exception that if the first two characters in the file are ! .Ql #n , the default output is suppressed. This is the same as specifying the .Fl n *************** *** 494,500 **** .El .Pp The ! .Nm sed utility exits 0 on success or >0 if an error occurred. .Sh SEE ALSO .Xr awk 1 , --- 487,493 ---- .El .Pp The ! .Nm utility exits 0 on success or >0 if an error occurred. .Sh SEE ALSO .Xr awk 1 , *************** *** 504,515 **** .Xr re_format 7 .Sh HISTORY A ! .Nm sed command appeared in .At v7 . .Sh STANDARDS The ! .Nm sed function is expected to be a superset of the .St -p1003.2 specification. --- 497,508 ---- .Xr re_format 7 .Sh HISTORY A ! .Nm command appeared in .At v7 . .Sh STANDARDS The ! .Nm function is expected to be a superset of the .St -p1003.2 specification.