mod_sed.html.en revision 5effc8b39fae5cd169d17f342bfc265705840014
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<?xml version="1.0" encoding="ISO-8859-1"?>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
7db058a7846888b8823fca9e8135f395265ef1d8nilgun XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7db058a7846888b8823fca9e8135f395265ef1d8nilgun This file is generated from xml source: DO NOT EDIT
7db058a7846888b8823fca9e8135f395265ef1d8nilgun XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7db058a7846888b8823fca9e8135f395265ef1d8nilgun -->
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<title>mod_sed - Apache HTTP Server</title>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<link href="/images/favicon.ico" rel="shortcut icon" /></head>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<body>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div id="page-header">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<p class="apache">Apache HTTP Server Version 2.5</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<img alt="" src="/images/feather.gif" /></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div id="path">
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div id="page-content">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div id="preamble"><h1>Apache Module mod_sed</h1>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="toplang">
d3bd91523e4565551991605fb157fea59c3610e2gryzor<p><span>Available Languages: </span><a href="/en/mod/mod_sed.html" title="English">&nbsp;en&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Filter Input (request) and Output (response) content using <code>sed</code> syntax</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>sed_module</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3 and later</td></tr></table>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<h3>Summary</h3>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> is an in-process content filter. The <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> filter implements the <code>sed</code> editing
50cb7e2b30597f481fee57bac945190f06ebcc58jortoncommands implemented by the Solaris 10 <code>sed</code>
50cb7e2b30597f481fee57bac945190f06ebcc58jortonprogram as described in the <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">manual
50cb7e2b30597f481fee57bac945190f06ebcc58jortonpage</a>. However, unlike <code>sed</code>, <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> doesn't take data from
7db058a7846888b8823fca9e8135f395265ef1d8nilgunstandard
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctonyinput. Instead, the filter acts on the entity data sent between client and
50cb7e2b30597f481fee57bac945190f06ebcc58jortonserver. <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> can be used as an input or output filter. <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> is a
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctonycontent filter, which means that it cannot be used to modify client or
7db058a7846888b8823fca9e8135f395265ef1d8nilgunserver http headers.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p>
50cb7e2b30597f481fee57bac945190f06ebcc58jortonThe <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> output filter accepts a chunk of data, executes the <code>sed</code> scripts on the data, and generates the output which is passed to the next filter in the chain.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p>
50cb7e2b30597f481fee57bac945190f06ebcc58jortonThe <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code> input filter reads the data from the next filter in the chain, executes the <code>sed</code> scripts, and returns the generated data to the caller filter in the filter chain.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p>
50cb7e2b30597f481fee57bac945190f06ebcc58jortonBoth the input and output filters only process the data if newline characters are seen in the content. At the end of the data, the rest of the data is treated as the last line.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<p>A tutorial article on <code class="module"><a href="/mod/mod_sed.html">mod_sed</a></code>, and why it is more powerful than simple
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctonystring or regular expression search and replace, is available <a href="http://blogs.sun.com/basant/entry/using_mod_sed_to_filter">on
7db058a7846888b8823fca9e8135f395265ef1d8nilgunthe author's blog</a>.</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div id="quickview"><h3 class="directives">Directives</h3>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<ul id="toc">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<li><img alt="" src="/images/down.gif" /> <a href="#inputsed">InputSed</a></li>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<li><img alt="" src="/images/down.gif" /> <a href="#outputsed">OutputSed</a></li>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</ul>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<h3>Topics</h3>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<ul id="topics">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<li><img alt="" src="/images/down.gif" /> <a href="#sampleconf">Sample Configuration</a></li>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<li><img alt="" src="/images/down.gif" /> <a href="#sed_commands">Sed Commands</a></li>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</ul></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="section">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<h2><a name="sampleconf" id="sampleconf">Sample Configuration</a></h2>
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctony <div class="example"><h3>Adding an output filter </h3><p><code>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # In the following example, the sed filter will change the string<br />
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # "monday" to "MON" and the string "sunday" to SUN in html documents<br />
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # before sending to the client.<br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <span class="indent">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun &lt;Directory "/var/www/docs/sed"&gt; <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <span class="indent">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun AddOutputFilter Sed html <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun OutputSed "s/monday/MON/g" <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun OutputSed "s/sunday/SUN/g" <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </span>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun &lt;/Directory&gt; <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </span>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </code></p></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctony <div class="example"><h3>Adding an input filter </h3><p><code>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # In the following example, the sed filter will change the string<br />
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # "monday" to "MON" and the string "sunday" to SUN in the POST data<br />
50cb7e2b30597f481fee57bac945190f06ebcc58jorton # sent to PHP.<br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <span class="indent">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun &lt;Directory "/var/www/docs/sed"&gt; <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <span class="indent">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun AddInputFilter Sed php <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun InputSed "s/monday/MON/g" <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun InputSed "s/sunday/SUN/g" <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </span>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun &lt;/Directory&gt; <br />
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </span>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </code></p></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="section">
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<h2><a name="sed_commands" id="sed_commands">Sed Commands</a></h2>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <p>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton Complete details of the <code>sed</code> command can be found from the
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">sed manual
7db058a7846888b8823fca9e8135f395265ef1d8nilgunpage</a>.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dl>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>b</code></dt>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <dd>Branch to the label specified (similar to goto).</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>h</code></dt>
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctony <dd>Copy the current line to the hold buffer.</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>H</code></dt>
c9f4eb2763c1d6ba9a3d26828e1729e476d0bb1epctony <dd>Append the current line to the hold buffer.</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>g</code></dt>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <dd>Copy the hold buffer to the current line.</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>G</code></dt>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <dd>Append the hold buffer to the current line.</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun <dt><code>x</code></dt>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <dd>Swap the contents of the hold buffer and the current line.</dd>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </dl>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="directive-section"><h2><a name="InputSed" id="InputSed">InputSed</a> <a name="inputsed" id="inputsed">Directive</a></h2>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<table class="directive">
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sed command to filter request data (typically <code>POST</code> data)</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>InputSed <var>sed-command</var></code></td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</table>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <p>The <code class="directive">InputSed</code> directive specifies the <code>sed</code> command
50cb7e2b30597f481fee57bac945190f06ebcc58jorton to execute on the request data e.g., <code>POST</code> data.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="directive-section"><h2><a name="OutputSed" id="OutputSed">OutputSed</a> <a name="outputsed" id="outputsed">Directive</a></h2>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<table class="directive">
50cb7e2b30597f481fee57bac945190f06ebcc58jorton<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sed command for filtering response content</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>OutputSed <var>sed-command</var></code></td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</table>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton <p>The <code class="directive">OutputSed</code> directive specifies the <code>sed</code>
50cb7e2b30597f481fee57bac945190f06ebcc58jorton command to execute on the response.
7db058a7846888b8823fca9e8135f395265ef1d8nilgun </p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<div class="bottomlang">
d3bd91523e4565551991605fb157fea59c3610e2gryzor<p><span>Available Languages: </span><a href="/en/mod/mod_sed.html" title="English">&nbsp;en&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</div><div id="footer">
5effc8b39fae5cd169d17f342bfc265705840014rbowen<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
7db058a7846888b8823fca9e8135f395265ef1d8nilgun</body></html>