sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

sed.1 (4028B)


      1 .Dd 2015-10-08
      2 .Dt SED 1
      3 .Os sbase
      4 .Sh NAME
      5 .Nm sed
      6 .Nd stream editor
      7 .Sh SYNOPSIS
      8 .Nm
      9 .Op Fl nrE
     10 .Ar script
     11 .Op Ar file ...
     12 .Nm
     13 .Op Fl nrE
     14 .Fl e Ar script
     15 .Op Fl e Ar script
     16 .Ar ...
     17 .Op Fl f Ar scriptfile
     18 .Ar ...
     19 .Op Ar file ...
     20 .Nm
     21 .Op Fl nrE
     22 .Op Fl e Ar script
     23 .Ar ...
     24 .Fl f Ar scriptfile
     25 .Op Fl f Ar scriptfile
     26 .Ar ...
     27 .Op Ar file ...
     28 .Sh DESCRIPTION
     29 .Nm
     30 reads line oriented output from
     31 .Ar file
     32 or stdin, applies the editing commands supplied by
     33 .Ar script
     34 or
     35 .Ar scriptfile
     36 and writes the edited stream to stdout.
     37 .Sh OPTIONS
     38 .Bl -tag -width Ds
     39 .It Fl n
     40 Suppress default printing at the end of each cycle.
     41 .It Fl r E
     42 Use extended regular expressions
     43 .It Fl e Ar script
     44 Append
     45 .Ar script
     46 to the list of editing commands.
     47 .It Fl f Ar scriptfile
     48 Append the commands from
     49 .Ar scriptfile
     50 to the list of editing commands.
     51 .El
     52 .Sh EXTENDED DESCRIPTION
     53 Editing commands take the form
     54 .Pp
     55 [address[,address]]function
     56 .Ss Addresses
     57 Addresses are either blank, a positive decimal integer denoting a line
     58 number, the character '$' denoting the last line of input, or a regular
     59 expression. A command with no addresses matches every line, one address
     60 matches individual lines, and two addresses matches a range of lines
     61 from the first to the second address inclusive.
     62 .Ss Functions
     63 .Bl -tag -width Ds
     64 .It Ar a Op Ar text
     65 Append text to output after end of current cycle.
     66 .It Ar b Op Ar label
     67 Branch to label. If no label is provided branch to end of script.
     68 .It Ar c Op Ar text
     69 Change. Delete addressed range and output text after end of current cycle.
     70 .It Ar d
     71 Delete pattern space and begin next cycle.
     72 .It Ar D
     73 Delete pattern space up to and including first newline and begin new
     74 cycle without reading input. If there is no newline, behave like d.
     75 .It Ar g
     76 Get. Replace the pattern space with the hold space.
     77 .It Ar G
     78 Get. Append a newline and the hold space to the pattern space.
     79 .It Ar h
     80 Hold. Replace the hold space with the pattern space.
     81 .It Ar H
     82 Hold. Append a newline and the pattern space to the hold space.
     83 .It Ar i Op Ar text
     84 Insert text in output.
     85 .It Ar l
     86 List? Write the pattern space replacing known non printing characters with
     87 backslash escaped versions (\\\\, \\a, \\b, \\f, \\r, \\t, \\v). Print
     88 bad UTF-8 sequences as \\ooo where ooo is a three digit octal number. Mark
     89 end of lines with '$'.
     90 .It Ar n
     91 Next. Write pattern space (unless
     92 .Fl n ) ,
     93 read next line into pattern space, and continue current cycle. If there
     94 is no next line, quit.
     95 .It Ar N
     96 Next. Read next line, append newline and next line to pattern space,
     97 and continue cycle. If there is no next line, quit without printing
     98 current pattern space.
     99 .It Ar p
    100 Print current pattern space.
    101 .It Ar P
    102 Print current pattern space up to first newline.
    103 .It Ar q
    104 Quit.
    105 .It Ar r file
    106 Read file and write contents to output.
    107 .It Ar s/re/text/flags
    108 Find occurences of regular expression re in the pattern space and replace
    109 with text. A '&' in text is replaced with the entire match. A \\d where
    110 d is a decimal digit 1-9 is replaced with the corresponding match group
    111 from the regular expression. \\n represents a newline in both the regular
    112 expression and replacement text. A literal newline in the replacement
    113 text must be preceded by a \\.
    114 .Pp
    115 Flags are
    116 .Bl -tag -width Ds
    117 .It Ar n
    118 A positive decimal number denoting which match in the pattern space
    119 to replace.
    120 .It Ar g
    121 Global. Replace all matches in the pattern space.
    122 .It Ar p
    123 Print the pattern if a replacement was made.
    124 .It Ar w file
    125 Write the pattern space to file if a replacement was made.
    126 .El
    127 .It Ar t Op Ar label
    128 Test. Branch to corresponding labelif a substitution has been made since
    129 the last line was read or last t command was executed. If no label is
    130 provided branch to end of script.
    131 .It Ar w file
    132 Write pattern space to file.
    133 .It Ar x
    134 Exchange hold space and pattern space.
    135 .It Ar y/set1/set2/
    136 Replace each occurrence of a character from set 1 with the corresponding
    137 character from set 2.
    138 .It Ar :label
    139 Create a label for b and t commands.
    140 .It Ar =
    141 Write current input line number to output.
    142 .El