SUPER-SED(1)
π NAME π
ssed β ok bestie, it's the super sed stream editor, version 3.61 β¨ Like regular sed but extra. We love her.
π¦ SYNOPSIS π¦
sed [OPTION]... {script-only-if-no-other-script} [input-file]...
πΈ DESCRIPTION πΈ
So sed is a stream editor. And a stream editor does basic text transformations on an input stream β that stream being either a file, or input coming at you from a pipeline π«Ά
And like, yeah, in some ways she's similar to an editor that lets you script your edits (think ed), but here's the thing: sed makes only one pass over the input(s), which is lowkey why she's so much more efficient. But honestly? It's her ability to filter text inside a pipeline that really sets her apart from every other type of editor. main character energy, fr fr π
β¨ OPTIONS β¨
-n,--quiet,--silentβ suppresses the automatic printing of the pattern space. (Shhh π€« she just won't print unless you tell her to.)-e script,--expression=scriptβ adds script to the commands that are gonna be executed.-f script-file,--file=script-fileβ adds the contents of script-file to the commands that are gonna be executed.-i[SUFFIX],--in-place[=SUFFIX]β edits files in place (and makes a backup if you supply an extension πΎ).-l N,--line-length=Nβ specifies the desired line-wrap length for thelcommand.--posixβ disables all GNU extensions. No cap.-r,--regexp-extendedβ use extended regular expressions in the script.-R,--regexp-perlβ use Perl 5's regular expressions syntax in the script. πͺ-s,--separateβ treats files as separate, rather than as one single continuous long stream.-u,--unbufferedβ loads minimal amounts of data from the input files and flushes the output buffers more often.--helpβ displays this help and exits.--versionβ outputs version info and exits.
So here's the tea: if you don't give her a -e, --expression, -f, or --file option, then the first non-option argument gets taken as the sed script to interpret. And every remaining argument after that? Those are the names of the input files ποΈ If you specify no input files at all, then standard input is read. Periodt.
π§ E-mail bug reports to:bonzini@gnu.org. Bestie, be sure to include the word`ssed`somewhere in the`Subject:`field, okay?? π
She's based on GNU sed version 4.1. π
π COMMAND SYNOPSIS π
This is just a lil brief synopsis of sed commands β a reminder for the girlies who already know sed π For fuller descriptions you must consult other documentation (like the texinfo document). Iykyk.
π Zero-address `commands` π
:label β label forbandtcommands.#commentβ the comment extends until the next newline (or the end of a-escript fragment).}β the closing bracket of a{ }block.
π Zero- or One- address commands π
=β print the current line number.a \followed bytextβ append text, which has each embedded newline preceded by a backslash.i \followed bytextβ insert text, which has each embedded newline preceded by a backslash.qβ immediately quit the sed script without processing any more input, except that if auto-print is not disabled the current pattern space will be printed.Qβ immediately quit the sed script without processing any more input.r filenameβ append text read from filename.R filenameβ append a line read from filename.
π§ Commands which accept address ranges π§
{β begin a block of commands (end with a}).b labelβ branch to label; if label is omitted, branch to end of script.t labelβ if as///has done a successful substitution since the last input line was read and since the lasttorTcommand, then branch to label; if label is omitted, branch to end of script.T labelβ if nos///has done a successful substitution since the last input line was read and since the lasttorTcommand, then branch to label; if label is omitted, branch to end of script.c \followed bytextβ replace the selected lines with text, which has each embedded newline preceded by a backslash.dβ delete pattern space. Start next cycle.Dβ delete up to the first embedded newline in the pattern space. Start next cycle, but skip reading from the input if there is still data in the pattern space.h Hβ copy/append pattern space to hold space.g Gβ copy/append hold space to pattern space.xβ exchange the contents of the hold and pattern spaces.lβ list out the current line in a`visually unambiguous`form.n Nβ read/append the next line of input into the pattern space.pβ print the current pattern space.Pβ print up to the first embedded newline of the current pattern space.s/regexp/replacement/β attempt to match regexp against the pattern space. If successful, replace that portion matched with replacement. The replacement may contain the special character&to refer to that portion of the pattern space which matched, and the special escapes\1through\9to refer to the corresponding matching sub-expressions in the regexp. π₯w filenameβ write the current pattern space to filename.W filenameβ write the first line of the current pattern space to filename.y/source/dest/β transliterate the characters in the pattern space which appear in source to the corresponding character in dest.
π Addresses π
Sed commands can be given with no addresses, in which case the command will be executed for all input lines. With one address, in which case the command will only be executed for input lines which match that address. Or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. π«Ά
Three things to note about address ranges, bestie, write these down:
- the syntax is
addr1,addr2(i.e., the addresses are separated by a comma); - the line which addr1 matched will always be accepted, even if addr2 selects an earlier line;
- and if addr2 is a regexp, it will not be tested against the line that addr1 matched.
After the address (or address-range), and before the command, a ! may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match.
The following address types are supported:
numberβ match only the specified line number.first~stepβ match every step'th line starting with line first. For example,`sed -n 1~2p`will print all the odd-numbered lines in the input stream, and the address2~5will match every fifth line, starting with the second. (This is an extension.)$β match the last line./regexp/β match lines matching the regular expression regexp.\cregexpcβ match lines matching the regular expression regexp. The c may be any character.
GNU sed also supports some special 2-address forms π:
0,addr2β start out in "matched first address" state, until addr2 is found. This is similar to1,addr2, except that if addr2 matches the very first line of input the0,addr2form will be at the end of its range, whereas the1,addr2form will still be at the beginning of its range.addr1,+Nβ will match addr1 and the N lines following addr1.addr1,~Nβ will match addr1 and the lines following addr1 until the next line whose input line number is a multiple of N.
β REGULAR EXPRESSIONS β
POSIX.2 BREs should be supported, but they aren't completely, because of performance problems π The \n sequence in a regular expression matches the newline character, and similarly for \a, \t, and other sequences.
π BUGS π
E-mail bug reports to bonzini@gnu.org. Be sure to include the word `sed` somewhere in the `Subject:` field. Also, please include the output of `sed --version` in the body of your report if at all possible π (girl, it genuinely helps)
π COPYRIGHT π
Copyright Β© 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law. π«£ Like, none. Zero. Nada.
π SEE ALSO π
awk(1), ed(1), grep(1), tr(1), perlre(1), sed.info, any of various books on sed, the sed FAQ (http://sed.sf.net/grabbag/tutorials/sedfaq.html), http://sed.sf.net/grabbag/. π
The full documentation for super-sed is maintained as a Texinfo manual. If the info and super-sed programs are properly installed at your site, the command
info sed
should give you access to the complete manual. β¨
And that's the whole page, bestie!! π¦ This was super-sed version 3.61, dated February 2005, and it lives in section 1 β SUPER-SED(1) π Go forth and stream-edit, you absolute icon. ππ
π¦ where this page comes from
- debian bookworm: ssed 3.62-8 Β· GPL-2.0-or-later
- ubuntu jammy: ssed 3.62-8 Β· GPL-2.0-or-later
- ubuntu noble: ssed 3.62-8 Β· GPL-2.0-or-later
- ubuntu resolute: ssed 3.62-8.1 Β· GPL-2.0-or-later
- ubuntu stonking: ssed 3.62-8.1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms