Registered by Registry Administrators

A heavily enhanced version of "sed", available from the upstream authers of sed.

ssed (super-sed) is a customized version of GNU sed which supports Perl-style regular expressions and features in its commands for s/ubstitu/tion/ and /addressing/. ssed is maintained by Paolo Bonzini (bonzini@gnu.org). The latest version of ssed can always be found on the ssed home page.

      http://sed.sourceforge.net/grabbag/ssed/

A summary of some of the features supported in ssed:

(1) Can be used in /addressing/ or on the FIND side of s/// commands:

     \` - matches the beginning of the pattern space: same as "^"
     \' - matches the end of the pattern space: same as "$"
     \? - 0 or 1 occurrences of previous char: same as \{0,1\}
     \+ - 1 or more occurrences of previous char: same as \{1,\}
     \| - matches the string on either side, e.g., foo\|bar
     \b - boundary between word and nonword chars (reversible)
     \B - boundary between 2 word or between 2 nonword chars
     \n - embedded newline (usable after N, G, or similar commands)
     \s - any whitespace character [space, TAB, VT, FF, \n]
     \S - any non-whitespace character
     \w - any word character: same as [A-Za-z0-9_]
     \W - any nonword char: same as [^A-Za-z0-9_]
     \< - boundary between nonword & word char (except in Perl-mode)
     \> - boundary between word & nonword char (except in Perl-mode)

     \(...\) - used for grouping; use ( or ) for literal parentheses
     \{M,N\} - used for interval exps.; use { or } for literal braces

(2) Supported for -r (extended regex) or -R (Perl-mode). NOTE: the -r
    switch is an undocumented option in GNU sed v3.02+.

     (...) - used for grouping; use \( or \) for literal parentheses
     {M,N} - used for interval exps.; use \{ or \} for literal braces
     ? - zero or one, instead of \?
     + - one or more, instead of \+
     | - alternation, instead of \|

(3) Can be used in /addressing/ or on EITHER side of an s/// cmd:

     \a - "alert" beep (BEL, Ctrl-G, 0x07)
     \f - formfeed (FF, Ctrl-L, 0x0C)
     \n - newline (LF, Ctrl-J, 0x0A)
     \r - carriage-return (CR, Ctrl-M, 0x0D)
     \t - horizontal tab (HT, Ctrl-I, 0x09)
     \v - vertical tab (VT, Ctrl-K, 0x0B)
     \cx - Ctrl-X (\cb is Ctrl-B, \cP is Ctrl-P, \cV is Ctrl-V, etc.)
     \oNNN - character with the octal value NNN (except in Perl-mode)
     \dNNN - character with the decimal value NNN (except in Perl-mode)
     \xNN - character with the hexadecimal value NN

(4) Case conversion, used only on the REPLACE side of an s/// command:

     \l - convert next char to lowercase
     \L - convert rest of line to lowercase
     \u - convert next char to uppercase
     \U - convert rest of line to uppercase
     \E - end case conversion begun by \L or \U

(5) In Perl-mode (-R switch), these become active or inactive:

     \A - matches beginning of pattern space
     \Z - matches end of pattern space or last newline in the PS
     \z - matches end of pattern space
     \d - matches any digit: same as [0-9]
     \D - matches any non-digit: same as [^0-9]
     \` - no longer matches beginning of pattern space
     \' - no longer matches end of pattern space
     \< - no longer matches boundary between nonword & word char
     \> - no longer matches boundary between word & nonword char
     \oNNN - no longer matches char with octal value NNN
     \dNNN - no longer matches char with decimal value NNN

(6) New switches in /addressing/ or s/// commands. Switches may be
    lowercase in s/// cmds, but must be uppercase in /addressing/.

   /I - ignore case in FIND patterns
   /M - multi-line patterns: ^ or $ will match BOL or EOL
   /S - Perl-mode ONLY: lets "." match a newline also
   /X - Perl-mode ONLY: extra whitespace is ignored. See section (9),
         below, for sample usage.

(6a) New switches in the s/// command (probably Perl-mode only)

   /e - evaluate the pattern space via a shell command, like Perl
   /ep - evaluate pattern space (as above), then print
   /pe - print pattern space (as above), then evaluate

   /w /dev/stderr - write the results to standard error
   /w /dev/stdout - write the results to standard output

(7) Perl-style regular expressions, with examples. Use the -R switch.
    Used in /addressing/ or the FIND side of s/// commands.

  (?i)abc - case-insensitive match of abc, ABC, aBc, ABc, etc.
  ab(?i)c - same as above; the (?i) applies throughout the pattern
  (ab(?i)c) - matches abc or abC; the outer parens make the difference!
  (?m) - multi-line pattern space: same as "s/FIND/REPL/M"
  (?s) - set "." to match newline also: same as "s/FIND/REPL/S"
  (?x) - ignore whitespace and #comments; see section (9) below.
  (?:abc)foo - match "abcfoo", but do not capture 'abc' in \1
  (?:ab|cd)ef - match "abef" or "cdef"; only 'cd' is captured in \1
  (?#remark)xy - match "xy"; remarks after "#" are ignored.

(8) Lookahead (?=match) and lookbehind (?<match) pattern matching.
    NB: the matched text is NOT captured in "&" for s/// replacements!

  foo(?=bar) - match "foo" only if "bar" follows it
  foo(?!bar) - match "foo" only if "bar" does NOT follow it
  (?<=foo)bar - match "bar" only if "foo" precedes it
  (?<!foo)bar - match "bar" only if "foo" does NOT precede it

  (?<!in|on|at)foo
     - match "foo" only if NOT preceded by "in", "on" or "at"

  (?<=\d{3})(?<!999)foo
     - match "foo" only if preceded by 3 digits other than "999"

(9) Sample use of /X switch to add comments to complex expressions.
    To embed literal spaces, precede with \ or put inside [brackets].

    # ssed script to change "(123) 456-7890" into "[ac123] 456-7890"
    #
    s/ # BACKSLASH IS NEEDED AT END OF EACH LINE! \
      \( # literal left paren, ( \
      (\d{3}) # 3 digits \
      \) # literal right paren, ) \
      [ \t]* # zero or more spaces or tabs \
      (\d{3}-\d{4}) # 3 digits, hyphen, 4 digits \
    /[ac\1] \2/gx; # replace g(lobally), with x(tended spacing)
    #
    # end of script

Project information

Maintainer:
Registry Administrators
Driver:
Not yet selected
Licence:
GNU GPL v2

RDF metadata

View full history Series and milestones

head series is the current focus of development.

All packages Packages in Distributions

Get Involved

  • warning
    Report a bug
  • warning
    Ask a question
  • warning
    Help translate

Downloads

ssed does not have any download files registered with Launchpad.