CINXE.COM
GNU sed - GNU Project - Free Software Foundation
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="author" href="mailto:webmasters@gnu.org" /> <link rel="icon" type="image/png" href="/graphics/gnu-head-mini.png" /> <meta name="ICBM" content="42.355469,-71.058627" /> <link rel="stylesheet" type="text/css" href="/layout.min.css" media="screen" /> <link rel="stylesheet" type="text/css" href="/print.min.css" media="print" /> <!-- Parent-Version: 1.92 --> <!-- This page is derived from /server/standards/boilerplate.html --> <title>GNU sed - GNU Project - Free Software Foundation</title> <link rel="stylesheet" type="text/css" href="sed.css" /> <!-- begin /server/gnun/initial-translations-list.html --> <!-- HTML head: set a flag for further expansion in body-include*.html. --> <!-- end /server/gnun/initial-translations-list.html --> <!-- start of server/banner.html --> <!-- start of head-include-2.html --> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" type="text/css" href="/server/banners/fundraiser.css" media="screen" /> <style type="text/css" media="screen"><!-- .progress-bar { width: 11%; } .percentage { text-align: left; left: 100%; padding-right: 1em; padding-left: .5em; } --></style> <style type="text/css" media="screen"> <!-- TRANSLATORS: Change direction to rtl if you translate the fundraiser and your script is right-to-left. --> #fundraiser { direction: ltr; } </style> <!-- end of head-include-2.html --> </head> <body> <div class="inner"> <!-- start of server/body-include-1.html --> <div id="top"> <p><a class="skip" href="#content"><b>Skip to main text</b></a></p> </div> <div id='fundraiser'> <div class="message"> <p class="headline"><b>Come build a better world with us!</b></p> <p><a href="https://my.fsf.org/donate?mtm_campaign=fall24&mtm_source=banner">Please don't scroll past this. We've been building a better world with free software since 1985. Today, we ask for your support. Only with your help can the FSF continue to be the cornerstone of a more just digital society! Donate to help us reach the goal of USD $400,000 by Dec 31.<span class="gnun-split"></span></a></p> <p class="button"><a href="https://my.fsf.org/donate?mtm_campaign=fall24&mtm_source=banner">Donate<span class="gnun-split"></span></a> </p> <div style="clear: both"></div> </div><!-- .message --> <div class="progress"> <div class="progress-bar"><span class="percentage">$46,778</span></div> <span class="goal">$400,000<span class="gnun-split"></span> </span> </div><!-- .progress --> </div><!-- #fundraiser --> <div style="clear: both"></div> <div id="header" role="banner"> <p id="gnu-banner"> <a href="/"> <img src="/graphics/heckert_gnu.transp.small.png" height="48" width="49" alt=" [A GNU head] " /><strong>GNU</strong> <span class="hide">Operating System</span></a><br /> <small id="fsf-support">Supported by the <a href="#mission-statement">Free Software Foundation</a></small> </p> <div id="switches"> <div id="search-button" class="switch"> <a href="//www.gnu.org/cgi-bin/estseek.cgi"> <img id="search-icon" height="30" width="30" src="/graphics/icons/search.png" alt=" [Search www.gnu.org] " /></a> </div> </div><!-- #switches --> </div><!-- #header --> <!-- end of server/body-include-1.html --> <!-- start of server/body-include-2 --> <div style="clear: both"></div> <div id="navigation" role="navigation"> <a id="more-links" href="#navigation" title="More..."> <span>Site navigation</span></a> <a id="less-links" href="#content"><b>Skip</b></a> <ul> <li id="tabAboutGNU"><a href="/gnu/gnu.html">ABOUT GNU</a></li> <li id="tabPhilosophy"><a href="/philosophy/philosophy.html">PHILOSOPHY</a></li> <li id="tabLicenses"><a href="/licenses/licenses.html">LICENSES</a></li> <li id="tabEducation"><a href="/education/education.html">EDUCATION</a></li> <li id="tabSoftware" class="active"> <span class='no-display'>=</span> <a href="/software/software.html">SOFTWARE</a> <span class="gnun-split"></span> <span class='no-display'>=</span> </li> <li id="tabDistros"><a href="/distros/distros.html">DISTROS</a></li> <li id="tabDoc"><a href="/doc/doc.html">DOCS</a></li> <li id="tabMalware"><a href="/proprietary/proprietary.html">MALWARE</a></li> <li id="tabHelp"><a href="/help/help.html">HELP GNU</a></li> <li id="tabAV"><a href="/audio-video/audio-video.html">AUDIO & VIDEO</a></li> <li id="tabArt"><a href="/graphics/graphics.html">GNU ART</a></li> <li id="tabFun"><a href="/fun/humor.html">FUN</a></li> <li id="tabPeople"><a href="/people/people.html">GNU'S WHO?</a></li> <li><a href="//directory.fsf.org">SOFTWARE DIRECTORY</a></li> <li><a href="https://h-node.org/">HARDWARE</a></li> <li><a href="/server/sitemap.html">SITEMAP</a></li> </ul> <div style="clear: both"></div> </div><!-- /"navigation --> <!-- end of server/body-include-2 --> <div id="content" role="main"> <!-- end of server/banner.html --> <div class="reduced-width"> <h2>GNU sed</h2> <hr class="thin" /> <p> sed (stream editor) is a non-interactive command-line text editor. </p> <pre class="example"> # Example: delete the 4th line in a file $ sed '4d' input.txt > output.txt # Example: replace every occurrence of 'hello' with 'world' on lines 10-20 $ sed '10,20s/hello/world/' input.txt > output.txt </pre> <p> sed is commonly used to filter text, i.e., it takes text input, performs some operation (or set of operations) on it, and outputs the modified text. sed is typically used for extracting part of a file using pattern matching or substituting multiple occurrences of a string within a file. </p> <div class="summary"> <h3 class="no-display">Table of Contents</h3> <ul> <li><a href="#help">Getting Help</a></li> <li><a href="#download">Downloads</a></li> <li><a href="#source">Latest Source</a></li> <li><a href="#mailinglists">Mailing Lists</a></li> <li><a href="#maintainers">Maintainers</a></li> </ul> <hr class="no-display" /> </div> <h3 id="help">Getting Help</h3> <ul> <!-- SED Manual --> <li> Read the manual locally using <kbd>info sed</kbd> or see the latest <a href="manual/">online manual</a>. </li> <!-- Search Mailing lists --> <li>Search the archives for previous questions and answers: <ul> <li>questions, development, and general discussion: <a href="https://lists.gnu.org/archive/html/sed-devel/"> sed-devel mailing list</a>; </li> <li>bug reports: <a href="https://lists.gnu.org/archive/html/bug-sed/"> bug-sed mailing list</a>. </li> </ul> </li> <!-- http://sed.sf.net --> <li>General sed resources are available at <a href="http://sed.sf.net">SourceForge.net</a>, including: <ul> <li> <a href="http://sed.sourceforge.net/#docs"> documentations, FAQ, one-liners</a>, </li> <li> <a href="http://sed.sourceforge.net/#books"> books</a>, and </li> <li> <a href="http://sed.sourceforge.net/#scripts"> example scripts</a>. </li> </ul> </li> <!-- http://translationproject.org/domain/sed.html --> <li> Send translation requests to the language team at the <a href="https://translationproject.org/domain/sed.html"> Translation Project</a>. </li> <!-- sed-devel@gnu.org for GENERAL QUESTIONS --> <li> Send general questions or suggestions to the mailing list at <<a href="mailto:sed-devel@gnu.org">sed-devel@gnu.org</a>>. </li> <!-- bug-sed@gnu.org for BUG REPORTS --> <li> Report bugs, including version and distribution variant, to the list at <<a href="mailto:bug-sed@gnu.org">bug-sed@gnu.org</a>>.<br/> Before sending the bug, please consult the FAQ and mailing list archives (above).<br/> Often these perceived bugs are simply due to wrong program usage.<br/> To learn more about reporting bugs, see <a href="/software/gethelp.html">Getting help with GNU software</a>. </li> </ul> <h3 id="download">Downloads</h3> <p> Stable source releases are available on the main GNU download server (<a href="https://ftp.gnu.org/gnu/sed/">HTTPS</a>, <a href="http://ftp.gnu.org/gnu/sed/">HTTP</a>, <a href="ftp://ftp.gnu.org/gnu/sed/">FTP</a>) and its <a href="/prep/ftp.html">mirrors</a>. Please <a href="https://ftpmirror.gnu.org/gnu/sed/">use a mirror</a> if possible. </p> <h3 id="source">Latest Source</h3> <p> The latest source with revision history can be browsed using <a href="https://git.sv.gnu.org/cgit/sed.git">cgit</a> or <a href="https://git.sv.gnu.org/gitweb/?p=sed.git">gitweb</a>. Assuming you have <a href="https://git-scm.com/">git</a> installed, you can retrieve the latest version with this command:</p> <pre class="emph-box"> <samp>git clone git://git.sv.gnu.org/sed</samp> </pre> <!-- TODO: add README-hacking to SED To build from the latest sources please follow the instructions in <a href="http://git.savannah.gnu.org/cgit/sed.git/plain/README-hacking">README-hacking</a><br/> --> <p> Please note that we do not suggest using test versions of sed for production use. </p> <!-- TODO: Add SED to all of the websites below <h3 id="testing">Third party testing resources</h3> <p> <ul> <li><a href="http://hydra.nixos.org/jobset/gnu/coreutils-master"> Hydra continuous integration jobs</a></li> <li><a href="https://scan.coverity.com/projects/29?tab=Overview"> Coverity static analysis</a></li> <li><a href="http://www.opencoverage.net/coreutils"> Open coverage test coverage report</a></li> <li><a href="http://hydra.nixos.org/job/gnu/coreutils-master/coverage/latest/log/tail-reload"> Latest Hydra test coverage results</a></li> </ul> </p> --> <h3 id="mailinglists">Mailing Lists</h3> <p> You do not need to be subscribed in order to post messages to any GNU mailing list. However non-subscribers are moderated by humans so please be patient when waiting for your email to arrive. </p> <p> You can subscribe to any GNU mailing list via the web as described below. Or you can send an empty mail with a <i>Subject:</i> header line of just “subscribe” to the relevant <i>-request</i> list. For example, to subscribe yourself to the main sed-devel list, you would send mail to <<a href="mailto:sed-devel-request@gnu.org">sed-devel-request@gnu.org</a>> with no body and a <i>Subject:</i> header line of just “subscribe”. </p> <p> It has been necessary to moderate the sed mailing lists to prevent the flood of spam. Postings to the lists are held for release by the list moderator. Sometimes the moderators are unavailable for brief periods of time. Please be patient when posting. If you don't eventually see the message in the list archive then it did not get posted. </p> <dl> <dt>Announcements</dt> <dd> <p> Important announcements about GNU sed and most other GNU Software are also made on the <a href="https://lists.gnu.org/mailman/listinfo/info-gnu"> info-gnu@gnu.org mailing list</a>. </p> </dd> <dt>Discussion List</dt> <dd> <p> The main discussion list for all things related to GNU sed is <a href="https://lists.gnu.org/mailman/listinfo/sed-devel">sed-devel@gnu.org</a>. If you have questions, comments, or other general discussion about sed then this is the mailing list for that discussion. If you don't know where to start then this is the place to start. You can browse and search past postings to the <a href="https://lists.gnu.org/archive/html/sed-devel/">sed-devel archive</a>. </p> </dd> <dt>Bug Reports</dt> <dd> <p> If you think you have found a bug in GNU sed, then please send as complete a bug report as possible to <a href="https://lists.gnu.org/mailman/listinfo/bug-sed">bug-sed@gnu.org</a>, and it will automatically be entered into the <a href="https://debbugs.gnu.org/sed"> sed bug tracker</a>. <!-- TODO: sed FAQ? Before reporting bugs please read the <a href="faq/coreutils-faq.html">FAQ</a>. --> A very useful and often referenced guide on how to write bug reports and ask good questions is the document <a href="http://www.catb.org/~esr/faqs/smart-questions.html"> How To Ask Questions The Smart Way</a>. You can browse previous postings and search the <a href="https://lists.gnu.org/archive/html/bug-sed/">bug-sed archive</a>. </p> </dd> <dt>Platform Testing</dt> <dd> <p> Trying the latest test release (when available) is always appreciated. Test releases of sed are typically announced on the <a href="https://lists.gnu.org/mailman/listinfo/platform-testers"> platform-testers</a> mailing list. </p> </dd> <dt>Enhancement Requests</dt> <dd> <p> If you would like any new feature to be included in future versions of sed, please send a request to <a href="https://lists.gnu.org/mailman/listinfo/sed-devel">sed-devel@gnu.org</a>. This is the general discussion list and a good place to start discussion of a new feature. After consideration you may be asked to log a request into the bug tracker so that the issue is not lost. If you would like to implement yourself, then note that non trivial changes require copyright assignment to the FSF as detailed in the “Copyright Assignment” <!-- TODO: add HACKING to sed --> section of GNU coreutils <a href="https://git.sv.gnu.org/cgit/coreutils.git/plain/HACKING">HACKING</a> notes. </p> </dd> <dt>Mailing List Etiquette</dt> <dd> <p> Please do not send messages encoded as HTML nor encoded as base64 MIME nor included as multiple formats. Please send messages as <a href="https://web.archive.org/web/20160305050159/http://stagecraft.theprices.net/nomime.html"> plain text</a>. Please include a descriptive subject line. If all of the subjects are <em>bug</em> then it is impossible to differentiate them. Please avoid sending large messages, such as log files, system call trace output, and other content resulting in messages over about 40 kB, to the mailing lists without prior contact. Those are best sent directly to those requesting that information after initial contact. </p> <p> Please remember that development of GNU sed is a volunteer effort, and you can also contribute to its development. For information about contributing to the GNU Project, please read <a href="/help/">How to help GNU</a>. </p> </dd> </dl> <h3 id="maintainers">Maintainers</h3> <p> GNU sed is currently being maintained by Jim Meyering <<a href="mailto:jim@meyering.net">jim@meyering.net</a>>, and Assaf Gordon <<a href="mailto:assafgordon@gmail.com">assafgordon@gmail.com</a>>. </p> </div> </div><!-- for id="content", starts in the include above --> <!-- begin server/footer-text.html --> <div style="clear:both"></div> <div id="mission-statement" role="complementary"> <div class="backtotop"> <hr class="no-display" /> <a href="#header"><span>BACK TO TOP </span>▲</a> </div> <div style="clear: both"></div> <blockquote> <p style="direction:ltr; text-align:left"><a href="//www.fsf.org"><img id="fsfbanner" src="/graphics/fsf-logo-notext-small.png" alt=" [FSF logo] " width="75" height="25" /></a><strong> “The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom. We defend the rights of all software users.”</strong></p> </blockquote> <div id="support-the-fsf" class="button"> <a class="join" href="//www.fsf.org/associate/support_freedom?referrer=4052">JOIN</a> <a class="donate" href="//donate.fsf.org/">DONATE</a> <a class="shop" href="//shop.fsf.org/">SHOP</a> </div> </div> <!-- end server/footer-text.html --> <div id="footer"> <div class="unprintable"> <p>Please send general FSF & GNU inquiries to <a href="mailto:gnu@gnu.org"><gnu@gnu.org></a>. There are also <a href="/contact/">other ways to contact</a> the FSF. Broken links and other corrections or suggestions can be sent to <a href="mailto:sed-devel@gnu.org"><em>sed-devel@gnu.org</em></a>. </p> <p>Please see the <a href="/server/standards/README.translations.html">Translations README</a> for information on coordinating and contributing translations of this article.</p> </div> <!-- Regarding copyright, in general, standalone pages (as opposed to files generated as part of manuals) on the GNU web server should be under CC BY-ND 4.0. Please do NOT change or remove this without talking with the webmasters or licensing team first. Please make sure the copyright date is consistent with the document. For web pages, it is ok to list just the latest year the document was modified, or published. If you wish to list earlier years, that is ok too. Either "2001, 2002, 2003" or "2001-2003" are ok for specifying years, as long as each year in the range is in fact a copyrightable year, i.e., a year in which the document was published (including being publicly visible on the web or in a revision control system). There is more detail about copyright years in the GNU Maintainers Information document, www.gnu.org/prep/maintain. --> <p>Copyright © 2013, 2014, 2015, 2016 Free Software Foundation, Inc.</p> <p>This page is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">Creative Commons Attribution-NoDerivatives 4.0 International License</a>.</p> <!-- start of server/bottom-notes.html --> <div id="bottom-notes" class="unprintable"> <p><a href="//www.fsf.org/about/dmca-notice">Copyright Infringement Notification</a></p> <div id="generic"> </div> </div> <!-- end of server/bottom-notes.html --> <p class="unprintable">Updated: <!-- timestamp start --> $Date: 2020/08/09 19:04:21 $ <!-- timestamp end --> </p> </div> </div> </body> </html>