{"id":345,"date":"2019-10-21T19:54:32","date_gmt":"2019-10-21T17:54:32","guid":{"rendered":"http:\/\/linuxboxen2.dk\/?p=345"},"modified":"2019-10-21T19:54:32","modified_gmt":"2019-10-21T17:54:32","slug":"sed","status":"publish","type":"post","link":"https:\/\/www.linuxboxen.dk\/?p=345","title":{"rendered":"SED"},"content":{"rendered":"<p>SED(1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 User Commands\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SED(1)<\/p>\n<p>NAME<\/p>\n<p>sed &#8211; stream editor for filtering and transforming text<\/p>\n<p>SYNOPSIS<\/p>\n<p>sed [OPTION]&#8230; {script-only-if-no-other-script} [input-file]&#8230;<\/p>\n<p>DESCRIPTION<\/p>\n<p>Sed is a stream editor.\u00a0 A stream editor is used to perform basic<br \/>\ntext transformations on an input stream (a file or input from a<br \/>\npipeline).\u00a0 While in some ways similar to an editor which permits<br \/>\nscripted edits (such as ed), sed works by making only one pass over<br \/>\nthe input(s), and is consequently more efficient.\u00a0 But it is sed&#8217;s<br \/>\nability to filter text in a pipeline which particularly distinguishes<br \/>\nit from other types of editors.<\/p>\n<p>-n, &#8211;quiet, &#8211;silent<\/p>\n<p>suppress automatic printing of pattern space<\/p>\n<p>-e script, &#8211;expression=script<\/p>\n<p>add the script to the commands to be executed<\/p>\n<p>-f script-file, &#8211;file=script-file<\/p>\n<p>add the contents of script-file to the commands to be executed<\/p>\n<p>&#8211;follow-symlinks<\/p>\n<p>follow symlinks when processing in place<\/p>\n<p>-i[SUFFIX], &#8211;in-place[=SUFFIX]<\/p>\n<p>edit files in place (makes backup if SUFFIX supplied)<\/p>\n<p>-l N, &#8211;line-length=N<\/p>\n<p>specify the desired line-wrap length for the `l&#8217; command<\/p>\n<p>&#8211;posix<\/p>\n<p>disable all GNU extensions.<\/p>\n<p>-r, &#8211;regexp-extended<\/p>\n<p>use extended regular expressions in the script.<\/p>\n<p>-s, &#8211;separate<\/p>\n<p>consider files as separate rather than as a single continuous<br \/>\nlong stream.<\/p>\n<p>-u, &#8211;unbuffered<\/p>\n<p>load minimal amounts of data from the input files and flush<br \/>\nthe output buffers more often<\/p>\n<p>-z, &#8211;null-data<\/p>\n<p>separate lines by NUL characters<\/p>\n<p>&#8211;help<br \/>\ndisplay this help and exit<\/p>\n<p>&#8211;version<br \/>\noutput version information and exit<\/p>\n<p>If no -e, &#8211;expression, -f, or &#8211;file option is given, then the first<br \/>\nnon-option argument is taken as the sed script to interpret.\u00a0 All<br \/>\nremaining arguments are names of input files; if no input files are<br \/>\nspecified, then the standard input is read.<\/p>\n<p>GNU sed home page: &lt;http:\/\/www.gnu.org\/software\/sed\/&gt;.\u00a0 General help<br \/>\nusing GNU software: &lt;http:\/\/www.gnu.org\/gethelp\/&gt;.\u00a0 E-mail bug<br \/>\nreports to: &lt;bug-sed@gnu.org&gt;.\u00a0 Be sure to include the word &#8220;sed&#8221;<br \/>\nsomewhere in the &#8220;Subject:&#8221; field.<\/p>\n<p>COMMAND SYNOPSIS<\/p>\n<p>This is just a brief synopsis of sed commands to serve as a reminder<br \/>\nto those who already know sed; other documentation (such as the<br \/>\ntexinfo document) must be consulted for fuller descriptions.<\/p>\n<p>Zero-address &#8220;commands&#8221;<br \/>\n: label<br \/>\nLabel for b and t commands.<\/p>\n<p>#comment<br \/>\nThe comment extends until the next newline (or the end of a -e<br \/>\nscript fragment).<\/p>\n<p>}\u00a0\u00a0\u00a0\u00a0\u00a0 The closing bracket of a { } block.<\/p>\n<p>Zero- or One- address commands<br \/>\n=\u00a0\u00a0\u00a0\u00a0\u00a0 Print the current line number.<\/p>\n<p>a \\<\/p>\n<p>text\u00a0\u00a0 Append text, which has each embedded newline preceded by a<br \/>\nbackslash.<\/p>\n<p>i \\<\/p>\n<p>text\u00a0\u00a0 Insert text, which has each embedded newline preceded by a<br \/>\nbackslash.<\/p>\n<p>q [exit-code]<br \/>\nImmediately quit the sed script without processing any more<br \/>\ninput, except that if auto-print is not disabled the current<br \/>\npattern space will be printed.\u00a0 The exit code argument is a<br \/>\nGNU extension.<\/p>\n<p>Q [exit-code]<br \/>\nImmediately quit the sed script without processing any more<br \/>\ninput.\u00a0 This is a GNU extension.<\/p>\n<p>r filename<br \/>\nAppend text read from filename.<\/p>\n<p>R filename<br \/>\nAppend a line read from filename.\u00a0 Each invocation of the<br \/>\ncommand reads a line from the file.\u00a0 This is a GNU extension.<\/p>\n<p>Commands which accept address ranges<br \/>\n{\u00a0\u00a0\u00a0\u00a0\u00a0 Begin a block of commands (end with a }).<\/p>\n<p>b label<br \/>\nBranch to label; if label is omitted, branch to end of script.<\/p>\n<p>c \\<\/p>\n<p>text\u00a0\u00a0 Replace the selected lines with text, which has each embedded<br \/>\nnewline preceded by a backslash.<\/p>\n<p>d\u00a0\u00a0\u00a0\u00a0\u00a0 Delete pattern space.\u00a0 Start next cycle.<\/p>\n<p>D\u00a0\u00a0\u00a0\u00a0\u00a0 If pattern space contains no newline, start a normal new cycle<br \/>\nas if the d command was issued.\u00a0 Otherwise, delete text in the<br \/>\npattern space up to the first newline, and restart cycle with<br \/>\nthe resultant pattern space, without reading a new line of<br \/>\ninput.<\/p>\n<p>h H\u00a0\u00a0\u00a0 Copy\/append pattern space to hold space.<\/p>\n<p>g G\u00a0\u00a0\u00a0 Copy\/append hold space to pattern space.<\/p>\n<p>l\u00a0\u00a0\u00a0\u00a0\u00a0 List out the current line in a &#8220;visually unambiguous&#8221; form.<\/p>\n<p>l width<br \/>\nList out the current line in a &#8220;visually unambiguous&#8221; form,<br \/>\nbreaking it at width characters.\u00a0 This is a GNU extension.<\/p>\n<p>n N\u00a0\u00a0\u00a0 Read\/append the next line of input into the pattern space.<\/p>\n<p>p\u00a0\u00a0\u00a0\u00a0\u00a0 Print the current pattern space.<\/p>\n<p>P\u00a0\u00a0\u00a0\u00a0\u00a0 Print up to the first embedded newline of the current pattern<br \/>\nspace.<\/p>\n<p>s\/regexp\/replacement\/<br \/>\nAttempt to match regexp against the pattern space.\u00a0 If<br \/>\nsuccessful, replace that portion matched with replacement.<br \/>\nThe replacement may contain the special character &amp; to refer<br \/>\nto that portion of the pattern space which matched, and the<br \/>\nspecial escapes \\1 through \\9 to refer to the corresponding<br \/>\nmatching sub-expressions in the regexp.<\/p>\n<p>t label<br \/>\nIf a s\/\/\/ has done a successful substitution since the last<br \/>\ninput line was read and since the last t or T command, then<br \/>\nbranch to label; if label is omitted, branch to end of script.<\/p>\n<p>T label<br \/>\nIf no s\/\/\/ has done a successful substitution since the last<br \/>\ninput line was read and since the last t or T command, then<br \/>\nbranch to label; if label is omitted, branch to end of script.<br \/>\nThis is a GNU extension.<\/p>\n<p>w filename<br \/>\nWrite the current pattern space to filename.<\/p>\n<p>W filename<br \/>\nWrite the first line of the current pattern space to filename.<br \/>\nThis is a GNU extension.<\/p>\n<p>x\u00a0\u00a0\u00a0\u00a0\u00a0 Exchange the contents of the hold and pattern spaces.<\/p>\n<p>y\/source\/dest\/<br \/>\nTransliterate the characters in the pattern space which appear<br \/>\nin source to the corresponding character in dest.<\/p>\n<p>Addresses<br \/>\nSed commands can be given with no addresses, in which case the<br \/>\ncommand will be executed for all input lines; with one address, in<br \/>\nwhich case the command will only be executed for input lines which<br \/>\nmatch that address; or with two addresses, in which case the command<br \/>\nwill be executed for all input lines which match the inclusive range<br \/>\nof lines starting from the first address and continuing to the second<br \/>\naddress.\u00a0 Three things to note about address ranges: the syntax is<br \/>\naddr1,addr2 (i.e., the addresses are separated by a comma); the line<br \/>\nwhich addr1 matched will always be accepted, even if addr2 selects an<br \/>\nearlier line; and if addr2 is a regexp, it will not be tested against<br \/>\nthe line that addr1 matched.<\/p>\n<p>After the address (or address-range), and before the command, a !<br \/>\nmay be inserted, which specifies that the command shall only be<br \/>\nexecuted if the address (or address-range) does not match.<\/p>\n<p>The following address types are supported:<\/p>\n<p>number Match only the specified line number (which increments<br \/>\ncumulatively across files, unless the -s option is specified<br \/>\non the command line).<\/p>\n<p>first~step<br \/>\nMatch every step&#8217;th line starting with line first.\u00a0 For<br \/>\nexample, &#8220;sed -n 1~2p&#8221; will print all the odd-numbered lines<br \/>\nin the input stream, and the address 2~5 will match every<br \/>\nfifth line, starting with the second.\u00a0 first can be zero; in<br \/>\nthis case, sed operates as if it were equal to step.\u00a0 (This is<br \/>\nan extension.)<\/p>\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0 Match the last line.<\/p>\n<p>\/regexp\/<br \/>\nMatch lines matching the regular expression regexp.<\/p>\n<p>\\cregexpc<br \/>\nMatch lines matching the regular expression regexp.\u00a0 The c may<br \/>\nbe any character.<\/p>\n<p>GNU sed also supports some special 2-address forms:<\/p>\n<p>0,addr2<br \/>\nStart out in &#8220;matched first address&#8221; state, until addr2 is<br \/>\nfound.\u00a0 This is similar to 1,addr2, except that if addr2<br \/>\nmatches the very first line of input the 0,addr2 form will be<br \/>\nat the end of its range, whereas the 1,addr2 form will still<br \/>\nbe at the beginning of its range.\u00a0 This works only when addr2<br \/>\nis a regular expression.<\/p>\n<p>addr1,+N<br \/>\nWill match addr1 and the N lines following addr1.<\/p>\n<p>addr1,~N<br \/>\nWill match addr1 and the lines following addr1 until the next<br \/>\nline whose input line number is a multiple of N.<\/p>\n<p>REGULAR EXPRESSIONS<\/p>\n<p>POSIX.2 BREs should be supported, but they aren&#8217;t completely because<br \/>\nof performance problems.\u00a0 The \\n sequence in a regular expression<br \/>\nmatches the newline character, and similarly for \\a, \\t, and other<br \/>\nsequences.<\/p>\n<p>BUGS<\/p>\n<p>E-mail bug reports to\u00a0bug-sed@gnu.org.\u00a0 Also, please include the<br \/>\noutput of &#8220;sed &#8211;version&#8221; in the body of your report if at all<br \/>\npossible.<\/p>\n<p>AUTHOR<\/p>\n<p>Written by Jay Fenlason, Tom Lord, Ken Pizzini, and Paolo Bonzini.<br \/>\nGNU sed home page: &lt;http:\/\/www.gnu.org\/software\/sed\/&gt;.\u00a0 General help<br \/>\nusing GNU software: &lt;http:\/\/www.gnu.org\/gethelp\/&gt;.\u00a0 E-mail bug<br \/>\nreports to: &lt;bug-sed@gnu.org&gt;.\u00a0 Be sure to include the word &#8220;sed&#8221;<br \/>\nsomewhere in the &#8220;Subject:&#8221; field.<\/p>\n<p>COPYRIGHT<\/p>\n<p>Copyright \u00a9 2012 Free Software Foundation, Inc.\u00a0 License GPLv3+: GNU<br \/>\nGPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;.<br \/>\nThis is free software: you are free to change and redistribute it.<br \/>\nThere is NO WARRANTY, to the extent permitted by law.<\/p>\n<p>SEE ALSO<\/p>\n<p>awk(1), ed(1), grep(1), tr(1), perlre(1), sed.info, any of various<br \/>\nbooks on sed, the sed FAQ<br \/>\n(http:\/\/sed.sf.net\/grabbag\/tutorials\/sedfaq.txt),<br \/>\nhttp:\/\/sed.sf.net\/grabbag\/.<\/p>\n<p>The full documentation for sed is maintained as a Texinfo manual.\u00a0 If<br \/>\nthe info and sed programs are properly installed at your site, the<br \/>\ncommand<\/p>\n<p>info sed<\/p>\n<p>should give you access to the complete manual.<\/p>\n<p>COLOPHON<\/p>\n<p>This page is part of the sed (stream-oriented editor) project.<br \/>\nInformation about the project can be found at<br \/>\n\u27e8http:\/\/www.gnu.org\/software\/sed\/\u27e9.\u00a0 If you have a bug report for this<br \/>\nmanual page, send it to\u00a0bug-sed@gnu.org.\u00a0 This page was obtained from<br \/>\nthe tarball sed-4.2.2.tar.gz fetched from<br \/>\n\u27e8https:\/\/www.gnu.org\/software\/sed\/\u27e9 on 2014-12-30.\u00a0 If you discover<br \/>\nany rendering problems in this HTML version of the page, or you<br \/>\nbelieve there is a better or more up-to-date source for the page, or<br \/>\nyou have corrections or improvements to the information in this<br \/>\nCOLOPHON (which is not part of the original manual page), send a mail<br \/>\nto\u00a0man-pages@man7.org<\/p>\n<p>sed 4.2.2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 December 2012\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SED(1)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SED(1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 User Commands\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SED(1) NAME sed &#8211; stream editor for filtering and transforming text SYNOPSIS sed [OPTION]&#8230; {script-only-if-no-other-script} [input-file]&#8230; DESCRIPTION Sed is a stream editor.\u00a0 A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).\u00a0 While in some ways similar to an editor which [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[8],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-shell"],"a3_pvc":{"activated":false,"total_views":0,"today_views":0},"_links":{"self":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}