blank.gif (43 bytes)

Church Of The
Swimming Elephant

Usage | Options | Commands | Expressions | Addresses

SED Regular Expressions

sed supports the basic regular expressions described on the regexp(5) manual page, with the following additions:


In a context address, the construction \cREc, where c is any character other than a backslash or NEWLINE character, is identical to /RE/. If the character designated by c appears following a backslash, then it is considered to be that literal character, which does not terminate the RE. For example, in the context address \xabc\xdefx, the second x stands for itself, so that the regular expression is abcxdef.
The escape sequence \n matches a NEWLINE character embedded in the pattern space. A literal NEWLINE character must not be used in the regular expression of a context address or in the substitute command.

Editing commands can be applied only to non-selected pattern spaces by use of the negation command ! (described below).
sed Editing Commands

In the following list of functions the maximum number of permissible addresses for each function is indicated.

The r and w commands take an optional rfile (or wfile) parameter, separated from the command letter by one or more blank characters.
Multiple commands can be specified by separating them with a semicolon (;) on the same command line.

The text argument consists of one or more lines, all but the last of which end with \ to hide the NEWLINE. Each embedded NEWLINE character in the text must be preceded by a backslash. Other backslashes in text are removed and the following character is treated literally. Backslashes in text are treated like backslashes in the replacement string of an s command, and may be used to protect initial blanks and tabs against the stripping that is done on every script line.

The rfile or wfile argument must terminate the command line and must be preceded by exactly one blank. The use of the wfile parameter causes that file to be initially created, if it does not exist, or will replace the contents of an existing file. There can be at most 10 distinct wfile arguments.

Regular expressions match entire strings, not just individual lines, but a NEWLINE character is matched by \n in a sed RE; a NEWLINE character is not allowed in an RE. Also note that \n cannot be used to match a NEWLINE character at the end of an input line; NEWLINE characters appear in the pattern space as a result of the N editing command.

Two of the commands take a command-list, which is a list of sed commands separated by NEWLINE characters, as follows:
{ command command }

The { can be preceded with blank characters and can be fol-lowed with white space. The commands can be preceded by white space. The terminating } must be preceded by a NEW-LINE character and can be preceded or followed by <blank>s. The braces may be preceded or followed by <blank>s. The command may be preceeded by <blank>s, but may not be followed by <blank>s.
The following table lists the functions, with the maximum number of permissible addresses.



Protect yourself from cyberstalkers, identity thieves, and those who would snoop on you.
Stop spam from invading your inbox without losing the mail you want. We give you more control over your e-mail than any other service.
Block popups, ads, and malicious scripts while you surf the net through our anonymous proxies.
Participate in Usenet, host your web files, easily send anonymous messages, and more, much more.
All private, all encrypted, all secure, all in an easy to use service, and all for only $5.95 a month!

Service Details

Have you gone to church today?
All pages ©1999, 2000, 2001, 2002, 2003 Church of the Swimming Elephant unless otherwise stated
Church of the Swimming Elephant©1999, 2000, 2001, 2002, 2003 is a wholly owned subsidiary of Packetderm, LLC.

Packetderm, LLC
210 Park Ave #308
Worcester, MA 01609