Subcommands31 subcommands
sed a
Appends `text` after a line
sed b
Branch unconditionally to `label`
sed c
Replace (change) lines with `text`
sed d
Delete the pattern space; immediately start next cycle
sed D
If pattern space contains newlines, delete text in the pattern space up to the first newline, and restart cycle with the resultant pattern space, without reading a new line of input. If pattern space contains no newline, start a normal new cycle as if the d command was issued
sed e
Executes the command that is found in pattern space and replaces the pattern space with the output; a trailing newline is suppressed
sed F
Prints the file name of the current input file
sed g
Replaces the contents of the pattern space with the contents of the hold space
sed G
Appends a newline to the contents of the pattern space, and then appends the contents of the hold space to that of the pattern space
sed h
Replaces the contents of the hold space with the contents of the pattern space
sed H
Appends a newline to the contents of the hold space, and then appends the contents of the pattern space to that of the hold space
sed i
Insert text before a line
sed l
Prints the pattern space in an unambiguous form
sed n
Prints the pattern space, then, regardless, replaces the pattern space with the next line of input. If there is no more input then sed exits without processing any more commands
sed N
Adds a newline to the pattern space, then appends the next line of input to the pattern space. If there is no more input then sed exits without processing any more commands
sed p
Prints the pattern space
sed P
Prints the pattern space up to the first newline
sed q
Exit sed without processing any more commands or input
sed Q
This command is the same as q, but will not print the contents of pattern space
sed R
Queue a line of filename to be read and inserted into the output stream at the end of the current cycle, or when the next input line is read
sed s
Match the regular-expression against the content of the pattern space. If found, replace matched string with replacement
sed t
(test) Branch to label only if there has been a successful substitution since the last input line was read or conditional branch was taken. The label may be omitted, in which case the next cycle is started
sed T
(test) Branch to label only if there have been no successful substitutions since the last input line was read or conditional branch was taken. The label may be omitted, in which case the next cycle is started
sed v
Makes sed fail if GNU sed extensions are not supported, or if the requested version is not available
sed w
Writes the pattern space to the file
sed W
Writes to the given filename the portion of the pattern space up to the first newline
sed x
Exchanges the contents of the hold and pattern spaces
sed y
Transliterate any characters in the pattern space which match any of the source-chars with the corresponding character in dest-chars
sed z
(zap) Empties the content of pattern space
sed #
Comment until the next newline
OptionsOn sed itself
-E
Interprets regular expressions as extended (modern) regular expressions rather than basic regular expressions
-a
Causes sed to delay opening each file until a command containing the related ``w'' function is applied to a line of input
-e
Appends the editing commands specified by the command argument to the list of commands <command>
-f
Appends the editing commands found in the file command_file to the list of commands. The editing commands should each be listed on a separate line <command_file>
-I
Edits files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved <extension>
-i
Edits files in-place similarly to `-I`, but treats each file independently from other files. In particular, line numbers in each file start at 1, the ``$'' address matches the last line of the current file, and address ranges are limited to the current file <extension>
-l
Makes output line buffered
-n
By default, each line of input is echoed to the standard output after all of the commands have been applied to it. The `-n` option suppresses this behavior
-r
Same as `-E` for compatibility with GNU sed
-u
Makes output unbuffered