=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sed/sed.1,v retrieving revision 1.36 retrieving revision 1.37 diff -c -r1.36 -r1.37 *** src/usr.bin/sed/sed.1 2010/09/03 11:09:29 1.36 --- src/usr.bin/sed/sed.1 2014/05/26 14:42:32 1.37 *************** *** 1,4 **** ! .\" $OpenBSD: sed.1,v 1.36 2010/09/03 11:09:29 jmc Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. --- 1,4 ---- ! .\" $OpenBSD: sed.1,v 1.37 2014/05/26 14:42:32 jmc Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. *************** *** 32,38 **** .\" .\" from: @(#)sed.1 8.2 (Berkeley) 12/30/93 .\" ! .Dd $Mdocdate: September 3 2010 $ .Dt SED 1 .Os .Sh NAME --- 32,38 ---- .\" .\" from: @(#)sed.1 8.2 (Berkeley) 12/30/93 .\" ! .Dd $Mdocdate: May 26 2014 $ .Dt SED 1 .Os .Sh NAME *************** *** 129,135 **** 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 --- 129,135 ---- character, into a .Em pattern space , (unless there is something left after a ! .Ic 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 *************** *** 227,233 **** representing zero, one, or two addresses. .Pp The argument ! .Em text consists of one or more lines. To embed a newline in the text, precede it with a backslash. Other backslashes in text are deleted and the following character --- 227,233 ---- representing zero, one, or two addresses. .Pp The argument ! .Ar text consists of one or more lines. To embed a newline in the text, precede it with a backslash. Other backslashes in text are deleted and the following character *************** *** 276,343 **** The terminating .Ql } must be preceded by a newline or optional whitespace. ! .Pp ! .Bl -tag -width "XXXXXXXX" -compact ! .It [2addr] Em function-list Execute ! .Em function-list only when the pattern space is selected. .Pp - .It [1addr] Ns Em a Ns \e - .It Em text - .Pp Write ! .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. ! .Pp ! .It [2addr] Ns Em b Ns [label] Branch to the ! .Sq \&: ! function with the specified label. If the label is not specified, branch to the end of the script. .Pp - .It [2addr] Ns Em c Ns \e - .It Em text - .Pp Delete the pattern space. With 0 or 1 address or at the end of a 2-address range, ! .Em text is written to the standard output. ! .Pp ! .It [2addr] Ns Em d Delete the pattern space and start the next cycle. ! .Pp ! .It [2addr] Ns Em D Delete the initial segment of the pattern space through the first newline character and start the next cycle. ! .Pp ! .It [2addr] Ns Em g Replace the contents of the pattern space with the contents of the hold space. ! .Pp ! .It [2addr] Ns Em G Append a newline character followed by the contents of the hold space to the pattern space. ! .Pp ! .It [2addr] Ns Em h Replace the contents of the hold space with the contents of the pattern space. ! .Pp ! .It [2addr] Ns Em H Append a newline character followed by the contents of the pattern space to the hold space. .Pp - .It [1addr] Ns Em i Ns \e - .It Em text - .Pp Write ! .Em text to the standard output. ! .Pp ! .It [2addr] Ns Em l (The letter ell.) Write the pattern space to the standard output in a visually unambiguous form. --- 276,338 ---- The terminating .Ql } must be preceded by a newline or optional whitespace. ! .Bl -tag -width Ds ! .It [2addr] Ar function-list Execute ! .Ar function-list only when the pattern space is selected. + .It Xo [1 addr] Ic a Ns \e + .br + .Ar text + .Xc .Pp Write ! .Ar text to standard output immediately before each attempt to read a line of input, whether by executing the ! .Ic N function or by beginning a new cycle. ! .It [2addr] Ns Ic b Bq Ar label Branch to the ! .Ic \&: ! function with the specified ! .Ar label . If the label is not specified, branch to the end of the script. + .It Xo [2addr] Ic c Ns \e + .br + .Ar text + .Xc .Pp Delete the pattern space. With 0 or 1 address or at the end of a 2-address range, ! .Ar text is written to the standard output. ! .It [2addr] Ns Ic d Delete the pattern space and start the next cycle. ! .It [2addr] Ns Ic D Delete the initial segment of the pattern space through the first newline character and start the next cycle. ! .It [2addr] Ns Ic g Replace the contents of the pattern space with the contents of the hold space. ! .It [2addr] Ns Ic G Append a newline character followed by the contents of the hold space to the pattern space. ! .It [2addr] Ns Ic h Replace the contents of the hold space with the contents of the pattern space. ! .It [2addr] Ns Ic H Append a newline character followed by the contents of the pattern space to the hold space. + .It Xo [1addr] Ic i Ns \e + .br + .Ar text + .Xc .Pp Write ! .Ar text to the standard output. ! .It [2addr] Ns Ic l (The letter ell.) Write the pattern space to the standard output in a visually unambiguous form. *************** *** 367,415 **** a backslash followed by a newline. The end of each line is marked with a .Ql $ . ! .Pp ! .It [2addr] Ns Em n Write the pattern space to the standard output if the default output has not been suppressed, and replace the pattern space with the next line of input. ! .Pp ! .It [2addr] Ns Em N Append the next line of input to the pattern space, using an embedded newline character to separate the appended material from the original contents. Note that the current line number changes. ! .Pp ! .It [2addr] Ns Em p Write the pattern space to standard output. ! .Pp ! .It [2addr] Ns Em P Write the pattern space, up to the first newline character to the standard output. ! .Pp ! .It [1addr] Ns Em q Branch to the end of the script and quit without starting a new cycle. ! .Pp ! .It [1addr] Ns Em r file Copy the contents of ! .Em file to the standard output immediately before the next attempt to read a line of input. If ! .Em file cannot be read for any reason, it is silently ignored and no error condition is set. ! .Pp ! .It [2addr] Ns Em s Ns /re/replacement/flags ! Substitute the replacement string for the first instance of the regular ! expression in the pattern space. Any character other than backslash or newline can be used instead of ! a slash to delimit the RE and the replacement. ! Within the RE and the replacement, the RE delimiter itself can be used as 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. --- 362,408 ---- a backslash followed by a newline. The end of each line is marked with a .Ql $ . ! .It [2addr] Ns Ic n Write the pattern space to the standard output if the default output has not been suppressed, and replace the pattern space with the next line of input. ! .It [2addr] Ns Ic N Append the next line of input to the pattern space, using an embedded newline character to separate the appended material from the original contents. Note that the current line number changes. ! .It [2addr] Ns Ic p Write the pattern space to standard output. ! .It [2addr] Ns Ic P Write the pattern space, up to the first newline character to the standard output. ! .It [1addr] Ns Ic q Branch to the end of the script and quit without starting a new cycle. ! .It [1addr] Ns Ic r Ar file Copy the contents of ! .Ar file to the standard output immediately before the next attempt to read a line of input. If ! .Ar file cannot be read for any reason, it is silently ignored and no error condition is set. ! .It [2addr] Ns Ic s Ns / Ns Ar RE Ns / Ns Ar replacement Ns / Ns Ar flags ! Substitute the ! .Ar replacement ! string for the first instance of the regular expression ! .Ar RE ! in the pattern space. Any character other than backslash or newline can be used instead of ! a slash to delimit the regular expression and the replacement. ! Within the regular expression and the replacement, ! the regular expression delimiter itself can be used as 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 ! regular expression. The special meaning of .Ql & in this context can be suppressed by preceding it by a backslash. *************** *** 426,507 **** a backslash. .Pp The value of ! .Em flags in the substitute function is zero or more of the following: .Bl -tag -width "XXXXXX" -offset indent ! .It 0 ... 9 Make the substitution only for the N'th occurrence of the regular expression in the pattern space. ! .It g Make the substitution for all non-overlapping matches of the regular expression, not just the first one. ! .It p Write the pattern space to standard output if a replacement was made. If the replacement string is identical to that which it replaces, it is still considered to have been a replacement. ! .It w Em file Append the pattern space to ! .Em file if a replacement was made. If the replacement string is identical to that which it replaces, it is still considered to have been a replacement. .El ! .Pp ! .It [2addr] Ns Em t Ns [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. ! .Pp ! .It [2addr] Ns Em w file Append the pattern space to the ! .Em file . ! .Pp ! .It [2addr] Ns Em x Swap the contents of the pattern and hold spaces. ! .Pp ! .It [2addr] Ns Em y Ns /string1/string2/ Replace all occurrences of characters in ! .Em string1 in the pattern space with the corresponding characters from ! .Em string2 . Any character other than a backslash or newline can be used instead of a slash to delimit the strings. Within ! .Em string1 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. ! .Pp ! .Sm off ! .It Xo [2addr] Em !function No ,\ \&[2addr] ! .Em !function-list ! .Xc ! .Sm on Apply the function or function-list only to the lines that are .Em not selected by the address(es). ! .Pp ! .It [0addr] Ns Em \&: Ns label ! This function does nothing; it bears a label to which the ! .Sq b and ! .Sq t commands may branch. ! .Pp ! .It [1addr] Ns Em = Write the line number to the standard output followed by a newline character. - .Pp .It [0addr] Empty lines are ignored. ! .Pp ! .It [0addr] Ns Em # The .Ql # and the remainder of the line are ignored (treated as a comment), with --- 419,491 ---- a backslash. .Pp The value of ! .Ar flags in the substitute function is zero or more of the following: .Bl -tag -width "XXXXXX" -offset indent ! .It Cm 0 No ... Cm 9 Make the substitution only for the N'th occurrence of the regular expression in the pattern space. ! .It Cm g Make the substitution for all non-overlapping matches of the regular expression, not just the first one. ! .It Cm p Write the pattern space to standard output if a replacement was made. If the replacement string is identical to that which it replaces, it is still considered to have been a replacement. ! .It Cm w Ar file Append the pattern space to ! .Ar file if a replacement was made. If the replacement string is identical to that which it replaces, it is still considered to have been a replacement. .El ! .It [2addr] Ns Ic t Bq Ar label Branch to the ! .Ic \&: ! function bearing the ! .Ar label ! if any substitutions have been made since the most recent reading of an input line or execution of a ! .Ic t function. If no label is specified, branch to the end of the script. ! .It [2addr] Ns Ic w Ar file Append the pattern space to the ! .Ar file . ! .It [2addr] Ns Ic x Swap the contents of the pattern and hold spaces. ! .It [2addr] Ns Ic y Ns / Ns Ar string1 Ns / Ns Ar string2 Ns / Replace all occurrences of characters in ! .Ar string1 in the pattern space with the corresponding characters from ! .Ar string2 . Any character other than a backslash or newline can be used instead of a slash to delimit the strings. Within ! .Ar string1 and ! .Ar 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. ! .It [2addr] Ns Ic \&! Ns Ar function , [2addr] Ns Ic \&! Ns Ar function-list Apply the function or function-list only to the lines that are .Em not selected by the address(es). ! .It [0addr] Ns Ic \&: Ns Ar label ! This function does nothing; it bears a ! .Ar label ! to which the ! .Ic b and ! .Ic t commands may branch. ! .It [1addr] Ns Ic = Write the line number to the standard output followed by a newline character. .It [0addr] Empty lines are ignored. ! .It [0addr] Ns Ic # The .Ql # and the remainder of the line are ignored (treated as a comment), with *************** *** 545,552 **** .Sh CAVEATS The use of semicolons to separate multiple commands is not permitted for the following commands: ! .Cm a , b , c , ! .Cm i , r , t , ! .Cm w , \&: , and ! .Cm # . --- 529,536 ---- .Sh CAVEATS The use of semicolons to separate multiple commands is not permitted for the following commands: ! .Ic a , b , c , ! .Ic i , r , t , ! .Ic w , \&: , and ! .Ic # .