hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

sed.1 (9104B)


      1 .\"
      2 .\" Sccsid @(#)sed.1	1.19 (gritter) 1/24/05
      3 .\" Derived from sed(1), Unix 7th edition:
      4 .\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
      5 .\"
      6 .\" Redistribution and use in source and binary forms, with or without
      7 .\" modification, are permitted provided that the following conditions
      8 .\" are met:
      9 .\"   Redistributions of source code and documentation must retain the
     10 .\"    above copyright notice, this list of conditions and the following
     11 .\"    disclaimer.
     12 .\"   Redistributions in binary form must reproduce the above copyright
     13 .\"    notice, this list of conditions and the following disclaimer in the
     14 .\"    documentation and/or other materials provided with the distribution.
     15 .\"   All advertising materials mentioning features or use of this software
     16 .\"    must display the following acknowledgement:
     17 .\"      This product includes software developed or owned by Caldera
     18 .\"      International, Inc.
     19 .\"   Neither the name of Caldera International, Inc. nor the names of
     20 .\"    other contributors may be used to endorse or promote products
     21 .\"    derived from this software without specific prior written permission.
     22 .\"
     23 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
     24 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
     25 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     26 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27 .\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
     28 .\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     31 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     32 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     33 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     34 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     35 .TH SED 1 "1/24/05" "Heirloom Toolchest" "User Commands"
     36 .SH NAME
     37 sed \- stream editor
     38 .SH SYNOPSIS
     39 \fBsed\fR [\fB\-n\fR] [\fB\-e\fI\ script\fR] [\fB\-f\fI\ sfile\fR]
     40 [\fIfile\fR\ .\ .\ .]
     41 .SH DESCRIPTION
     42 .I Sed
     43 copies the named
     44 .I files
     45 (standard input default) to the standard output,
     46 edited according to a script of commands.
     47 The
     48 .B \-f
     49 option causes the script to be taken from file
     50 .IR sfile ;
     51 these options accumulate.
     52 If there is just one
     53 .B \-e
     54 option and no
     55 .BR \-f 's,
     56 the flag
     57 .B \-e
     58 may be omitted.
     59 The
     60 .B \-n
     61 option suppresses the default output.
     62 .PP
     63 A script consists of editing commands, one per line,
     64 of the following form:
     65 .IP
     66 [address [, address] ] function [arguments]
     67 .PP
     68 In normal operation
     69 .I sed
     70 cyclically copies a line of input into a
     71 .I pattern space
     72 (unless there is something left after
     73 a `D' command),
     74 applies in sequence
     75 all commands whose
     76 .I addresses
     77 select that pattern space,
     78 and at the end of the script copies the pattern space
     79 to the standard output (except under
     80 .BR \-n )
     81 and deletes the pattern space.
     82 .PP
     83 An
     84 .I address
     85 is either a decimal number that counts
     86 input lines cumulatively across files, a `$' that
     87 addresses the last line of input, or a context address,
     88 `/regular expression/', in the style of
     89 .IR ed (1)
     90 modified thus:
     91 .IP
     92 The escape sequence `\en' matches a
     93 newline embedded in the pattern space.
     94 .IP
     95 A command line with no addresses selects every pattern space.
     96 .IP
     97 A command line with
     98 one address selects each pattern space that matches the address.
     99 .IP
    100 A command line with
    101 two addresses selects the inclusive range from the first
    102 pattern space that matches the first address through
    103 the next pattern space that matches 
    104 the second.
    105 (If the second address is a number less than or equal
    106 to the line number first selected, only one
    107 line is selected.)
    108 Thereafter the process is repeated, looking again for the
    109 first address.
    110 .PP
    111 Editing commands can be applied only to non-selected pattern
    112 spaces by use of the negation function `!' (below).
    113 .PP
    114 Regular expressions are simple regular expressions with
    115 .BR /usr/5bin/sed ,
    116 and basic regular expressions with
    117 .BR /usr/5bin/posix/sed ,
    118 .BR /usr/5bin/posix2001/sed ,
    119 and
    120 .BR /usr/5bin/s42/sed .
    121 .PP
    122 In the following list of functions the 
    123 maximum number of permissible addresses
    124 for each function is indicated in parentheses.
    125 .PP
    126 An argument denoted
    127 .I text
    128 consists of one or more lines,
    129 all but the last of which end with `\e' to hide the
    130 newline.
    131 Backslashes in text are treated like backslashes
    132 in the replacement string of an `s' command.
    133 .PP
    134 An argument denoted
    135 .I rfile
    136 or
    137 .I wfile
    138 must terminate the command
    139 line.
    140 .B /usr/5bin/sed
    141 and
    142 .B /usr/5bin/s42/sed
    143 require that it is
    144 preceded by exactly one blank.
    145 Each
    146 .I wfile
    147 is created before processing begins.
    148 .TP 10
    149 (1)\|\fBa\e\fR
    150 .br
    151 .ns
    152 .TP 10
    153 .I text
    154 Append.
    155 Place
    156 .I text
    157 on the output before
    158 reading the next input line.
    159 .TP 10
    160 (2)\|\fBb \fIlabel\fR
    161 Branch to the `:' command bearing the
    162 .IR label .
    163 If
    164 .I label
    165 is empty, branch to the end of the script.
    166 .TP 10
    167 (2)\|\fBc\e\fR
    168 .br
    169 .ns
    170 .TP 10
    171 .I text
    172 Change.
    173 Delete the pattern space.
    174 With 0 or 1 address or at the end of a 2-address range, place
    175 .I text
    176 on the output.
    177 Start the next cycle.
    178 .TP 10
    179 (2)\|\fBd\fR
    180 Delete the pattern space.
    181 Start the next cycle.
    182 .TP 10
    183 (2)\|\fBD\fR
    184 Delete the initial segment of the 
    185 pattern space through the first newline.
    186 Start the next cycle.
    187 .TP 10
    188 (2)\|\fBg\fR
    189 Replace the contents of the pattern space
    190 by the contents of the hold space.
    191 .TP 10
    192 (2)\|\fBG\fR
    193 Append the contents of the hold space to the pattern space.
    194 .TP 10
    195 (2)\|\fBh\fR
    196 Replace the contents of the hold space by the contents of the pattern space.
    197 .TP 10
    198 (2)\|\fBH\fR
    199 Append the contents of the pattern space to the hold space.
    200 .TP 10
    201 (1)\|\fBi\e\fR
    202 .br
    203 .ns
    204 .TP 10
    205 .I text
    206 Insert.
    207 Place
    208 .I text
    209 on the standard output.
    210 .TP 10
    211 (2)\|\fBl\fR
    212 List the pattern space on the standard output in an
    213 unambiguous form.
    214 Non-printing ASCII characters are spelled
    215 in two- or three-digit ASCII,
    216 and long lines are folded.
    217 .TP 10
    218 (2)\|\fBn\fR
    219 Copy the pattern space to the standard output.
    220 Replace the pattern space with the next line of input.
    221 .TP 10
    222 (2)\|\fBN\fR
    223 Append the next line of input to the pattern space
    224 with an embedded newline.
    225 (The current line number changes.)
    226 .TP 10
    227 (2)\|\fBp\fR
    228 Print.
    229 Copy the pattern space to the standard output.
    230 .TP 10
    231 (2)\|\fBP\fR
    232 Copy the initial segment of the pattern space through
    233 the first newline to the standard output.
    234 .TP 10
    235 (1)\|\fBq\fR
    236 Quit.
    237 Branch to the end of the script.
    238 Do not start a new cycle.
    239 .TP 10
    240 (2)\|\fBr \fIrfile\fR
    241 Read the contents of
    242 .IR rfile .
    243 Place them on the output before reading
    244 the next input line.
    245 .TP 10
    246 (2)\|\fBs/\fIregular\ expression\fB/\fIreplacement\fB/\fIflags\fR
    247 Substitute the
    248 .I replacement
    249 string for instances of the
    250 .I regular expression
    251 in the pattern space.
    252 Any character may be used instead of `/'.
    253 For a fuller description see
    254 .IR ed (1).
    255 .I Flags
    256 is zero or more of
    257 .RS
    258 .TP
    259 .B g
    260 Global.
    261 Substitute for all nonoverlapping instances of the
    262 .I regular expression
    263 rather than just the
    264 first one.
    265 .TP
    266 .I n
    267 \fIn\fR=1\^\(en\^512.
    268 Substitute the \fIn\fRth occurrence of the
    269 .I regular expression
    270 only.
    271 .TP
    272 .B p
    273 Print the pattern space if a replacement was made.
    274 .TP
    275 \fBw \fIwfile\fB
    276 Write.
    277 Append the pattern space to
    278 .I wfile
    279 if a replacement
    280 was made.
    281 .RE
    282 .TP 10
    283 (2)\|\fBt \fIlabel\fR
    284 Test.
    285 Branch to the `:' command bearing the
    286 .I label
    287 if any
    288 substitutions have been made since the most recent
    289 reading of an input line or execution of a `t'.
    290 If 
    291 .I label
    292 is empty, branch to the end of the script.
    293 .TP 10
    294 (2)\|\fBw \fIwfile\fR
    295 Write.
    296 Append the pattern space to
    297 .IR wfile .
    298 .TP 10
    299 (2)\|\fBx\fR
    300 Exchange the contents of the pattern and hold spaces.
    301 .TP 10
    302 (2)\|\fBy/\fIstring1\fB/\fIstring2\fB/\fR
    303 Transform.
    304 Replace all occurrences of characters in
    305 .I string1
    306 with the corresponding character in
    307 .I string2.
    308 The lengths of
    309 .I
    310 string1
    311 and
    312 .I string2
    313 must be equal.
    314 .TP 10
    315 (2)\fB! \fIfunction\fB
    316 Don't.
    317 Apply the
    318 .I function
    319 (or group, if
    320 .I function
    321 is `{') only to lines
    322 .I not
    323 selected by the address(es).
    324 .TP 10
    325 (0)\|\fB: \fIlabel\fR
    326 This command does nothing; it bears a
    327 .I label
    328 for `b' and `t' commands to branch to.
    329 .TP 10
    330 (1)\|\fB=\fR
    331 Place the current line number on the standard output as a line.
    332 .TP 10
    333 (2)\|\fB{\fR
    334 Execute the following commands through a matching `}'
    335 only when the pattern space is selected.
    336 .TP 10
    337 (0)\|
    338 An empty command is ignored.
    339 .TP 10
    340 (0)\|\fB#\fP
    341 Ignore the entire line,
    342 except when the first two characters in the script are \fB#n\fP,
    343 which has the same effect as the \f2\-n\fP command line option.
    344 .SH "ENVIRONMENT VARIABLES"
    345 .TP
    346 .BR LANG ", " LC_ALL
    347 See
    348 .IR locale (7).
    349 .TP 
    350 .B LC_COLLATE
    351 Affects the collation order for range expressions,
    352 equivalence classes, and collation symbols
    353 in basic regular expressions.
    354 .TP
    355 .B LC_CTYPE 
    356 Determines the mapping of bytes to characters
    357 in both simple and basic regular expressions,
    358 for the
    359 .B l
    360 and
    361 .B y
    362 commands,
    363 and the availability and composition of character classes
    364 in basic regular expressions.
    365 .SH SEE ALSO
    366 ed(1),
    367 grep(1),
    368 awk(1),
    369 locale(7)