sed: sed commands list
1
1 3.2 'sed' commands summary
1 ==========================
1
1 The following commands are supported in GNU 'sed'. Some are standard
1 POSIX commands, while other are GNU extensions. Details and examples
1 for each command are in the following sections. (Mnemonics) are shown
1 in parentheses.
1
1 'a\'
1 'TEXT'
1 Append TEXT after a line.
1
1 'a TEXT'
1 Append TEXT after a line (alternative syntax).
1
1 'b LABEL'
1 Branch unconditionally to LABEL. The LABEL may be omitted, in
1 which case the next cycle is started.
1
1 'c\'
1 'TEXT'
1 Replace (change) lines with TEXT.
1
1 'c TEXT'
1 Replace (change) lines with TEXT (alternative syntax).
1
1 'd'
1 Delete the pattern space; immediately start next cycle.
1
1 'D'
1 If pattern space contains newlines, delete text in the pattern
1 space up to the first newline, and restart cycle with the resultant
1 pattern space, without reading a new line of input.
1
1 If pattern space contains no newline, start a normal new cycle as
1 if the 'd' command was issued.
1
1 'e'
1 Executes the command that is found in pattern space and replaces
1 the pattern space with the output; a trailing newline is
1 suppressed.
1
1 'e COMMAND'
1 Executes COMMAND and sends its output to the output stream. The
1 command can run across multiple lines, all but the last ending with
1 a back-slash.
1
1 'F'
1 (filename) Print the file name of the current input file (with a
1 trailing newline).
1
1 'g'
1 Replace the contents of the pattern space with the contents of the
1 hold space.
1
1 'G'
1 Append a newline to the contents of the pattern space, and then
1 append the contents of the hold space to that of the pattern space.
1
1 'h'
1 (hold) Replace the contents of the hold space with the contents of
1 the pattern space.
1
1 'H'
1 Append a newline to the contents of the hold space, and then append
1 the contents of the pattern space to that of the hold space.
1
1 'i\'
1 'TEXT'
1 insert TEXT before a line.
1
1 'i TEXT'
1 insert TEXT before a line (alternative syntax).
1
1 'l'
1 Print the pattern space in an unambiguous form.
1
1 'n'
1 (next) If auto-print is not disabled, print the pattern space,
1 then, regardless, replace the pattern space with the next line of
1 input. If there is no more input then 'sed' exits without
1 processing any more commands.
1
1 'N'
1 Add a newline to the pattern space, then append the next line of
1 input to the pattern space. If there is no more input then 'sed'
1 exits without processing any more commands.
1
1 'p'
1 Print the pattern space.
1
1 'P'
1 Print the pattern space, up to the first <newline>.
1
1 'q[EXIT-CODE]'
1 (quit) Exit 'sed' without processing any more commands or input.
1
1 'Q[EXIT-CODE]'
1 (quit) This command is the same as 'q', but will not print the
1 contents of pattern space. Like 'q', it provides the ability to
1 return an exit code to the caller.
1
1 'r filename'
1 Reads file FILENAME.
1
1 'R filename'
1 Queue a line of FILENAME to be read and inserted into the output
1 stream at the end of the current cycle, or when the next input line
1 is read.
1
1 's/REGEXP/REPLACEMENT/[FLAGS]'
1 (substitute) Match the regular-expression against the content of
1 the pattern space. If found, replace matched string with
1 REPLACEMENT.
1
1 't LABEL'
1 (test) Branch to LABEL only if there has been a successful
1 's'ubstitution since the last input line was read or conditional
1 branch was taken. The LABEL may be omitted, in which case the next
1 cycle is started.
1
1 'T LABEL'
1 (test) Branch to LABEL only if there have been no successful
1 's'ubstitutions since the last input line was read or conditional
1 branch was taken. The LABEL may be omitted, in which case the next
1 cycle is started.
1
1 'v [VERSION]'
1 (version) This command does nothing, but makes 'sed' fail if GNU
1 'sed' extensions are not supported, or if the requested version is
1 not available.
1
1 'w filename'
1 Write the pattern space to FILENAME.
1
1 'W filename'
1 Write to the given filename the portion of the pattern space up to
1 the first newline
1
1 'x'
1 Exchange the contents of the hold and pattern spaces.
1
1 'y/src/dst/'
1 Transliterate any characters in the pattern space which match any
1 of the SOURCE-CHARS with the corresponding character in DEST-CHARS.
1
1 'z'
1 (zap) This command empties the content of pattern space.
1
1 '#'
1 A comment, until the next newline.
1
1 '{ CMD ; CMD ... }'
1 Group several commands together.
1
1 '='
1 Print the current input line number (with a trailing newline).
1
1 ': LABEL'
1 Specify the location of LABEL for branch commands ('b', 't', 'T').
1