home *** CD-ROM | disk | FTP | other *** search
- NAME
- sed - the stream editor
-
-
- SYNOPSIS
- sed [-n] [-g] [-e script ] [-f sfile ] [ file ] ...
-
-
- DESCRIPTION
- Sed copies the named files (standard input default) to the standard
- output, edited according to a script of commands.
- An -e option supplies a single edit command from the next argument;
- if there are several of these they are executed in the order in which
- they appear. If there is just one -e option and no -f 's, the -e flag
- may be omitted.
- An -f option causes commands to be taken from the file "sfile"; if
- there are several of these they are executed in the order in which
- they appear; -e and -f commands may be mixed.
- The -g option causes sed to act as though every substitute command
- in the script has a g suffix.
- The -n option suppresses the default output.
-
- A script consists of commands, one per line, of the following form:
-
- [address [, address] ] function [arguments]
-
- Normally sed cyclically copies a line of input into a current text
- buffer, then applies all commands whose addresses select the buffer in
- sequence, then copies the buffer to standard output and clears it.
- The -n option suppresses normal output (so that only p and w output
- is done). Also, some commands (n, N) do their own line reads, and some
- others (d, D) cause all commands following in the script to be skipped
- (the D command also suppresses the clearing of the current text buffer
- that would normally occur before the next cycle).
-
- It is also helpful to know that there's a second buffer (called the
- 'hold space' that can be copied or appended to or from or swapped with
- the current text buffer.
-
- An address is: a decimal numeral (which matches the line it numbers
- where line numbers start at 1 and run cumulatively across files), or a
- `$' that addresses the last line of input, or a context address, which
- is a `/regular expression/', in the style of ed (1) modified thus:
-
- (1) The escape sequence `\n' matches a newline embedded in the buffer,
- and `\t' matches a tab.
-
- (2) A command line with no addresses selects every buffer.
-
- (3) A command line with one address selects every buffer that matches
- that address.
-
- (4) A command line with two addresses selects the inclusive range from
- the first input buffer that matches the first address through the
- next input buffer that matches the second. (If the second address
- is a number less than or equal to the line number first selected,
- only one line is selected.) Once the second address is matched sed
- starts looking for the first one again; thus, any number of these
- ranges will be matched.
-
- The negation operator '!' can prefix a command to apply it to every
- line not selected by the address(es).
-
- In the following list of functions, the maximum number of addresses
- permitted for each function is indicated in parentheses.
- An argument denoted "text" consists of one or more lines, with all
- but the last ending with `\' to hide the newline.
- Backslashes in text are treated like backslashes i`נüâêOäê◆üÄ✓ ✓ ü≡ä⇧äé êOÇ✓נÄ נÅäHOî ë/* in an address range? */
- } flags;
- };
- typedef struct cmd_t sedcmd; /* use this name for declarations */
-
- #define BAD ((char *) -1) /* guaranteed not a string ptr */
-
-
- /* address and regular expression compiled-form markers */
- #define STAR 1 /* marker for Kleene star */
- #define CCHR 2 /* non-newline character to be matched follows */
- #define CDOT 4 /* dot wild-card marker */
- #define CCL 6 /* character class follows */
- #define CNL 8 /* match line start */
- #define CDOL 10 /* match line end */
- #define CBRA 12 /* tagged pattern start marker */
- #define CKET 14 /* tagged pattern end marker */
- #define CBACK 16 /* backslash-digit pair marker */
- #define CLNUM 18 /* numeric-address index follows */
- #define CEND 20 /* symbol for end-of-source */
- #define CEOF 22 /* end-of-field mark */
-
- /* sed.h ends here */