]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_sed.html.en
Merge in APR[-util] macros from branches/trunk-buildconf-noapr
[apache] / docs / manual / mod / mod_sed.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>mod_sed - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body>
19 <div id="page-header">
20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
24 <div id="path">
25 <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>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_sed</h1>
28 <div class="toplang">
29 <p><span>Available Languages: </span><a href="../en/mod/mod_sed.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="../fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
31 </div>
32 <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>
33 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
34 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>sed_module</td></tr>
35 <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>
36 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3 and later</td></tr></table>
37 <h3>Summary</h3>
38
39 <p>
40 <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
41 commands implemented by the Solaris 10 <code>sed</code>
42 program as described in the <a href="http://www.gnu.org/software/sed/manual/sed.txt">manual
43 page</a>. However, unlike <code>sed</code>, <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> doesn't take data from
44 standard
45 input. Instead, the filter acts on the entity data sent between client and
46 server. <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
47 content filter, which means that it cannot be used to modify client or
48 server http headers.
49 </p>
50 <p>
51 The <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.
52 </p>
53
54 <p>
55 The <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.
56 </p>
57
58 <p>
59 Both 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.
60 </p>
61
62 <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
63 string or regular expression search and replace, is available <a href="https://blogs.oracle.com/basant/entry/using_mod_sed_to_filter">on
64 the author's blog</a>.</p>
65
66 </div>
67 <div id="quickview"><h3>Topics</h3>
68 <ul id="topics">
69 <li><img alt="" src="../images/down.gif" /> <a href="#sampleconf">Sample Configuration</a></li>
70 <li><img alt="" src="../images/down.gif" /> <a href="#sed_commands">Sed Commands</a></li>
71 </ul><h3 class="directives">Directives</h3>
72 <ul id="toc">
73 <li><img alt="" src="../images/down.gif" /> <a href="#inputsed">InputSed</a></li>
74 <li><img alt="" src="../images/down.gif" /> <a href="#outputsed">OutputSed</a></li>
75 </ul>
76 <h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_sed">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&amp;component=mod_sed">Report a bug</a></li></ul><h3>See also</h3>
77 <ul class="seealso">
78 <li><a href="#comments_section">Comments</a></li></ul></div>
79 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
80 <div class="section">
81 <h2><a name="sampleconf" id="sampleconf">Sample Configuration</a></h2>
82     <div class="example"><h3>Adding an output filter </h3><pre class="prettyprint lang-config"># In the following example, the sed filter will change the string
83 # "monday" to "MON" and the string "sunday" to SUN in html documents
84 # before sending to the client.
85 &lt;Directory "/var/www/docs/sed"&gt;
86     AddOutputFilter Sed html
87     OutputSed "s/monday/MON/g"
88     OutputSed "s/sunday/SUN/g"
89 &lt;/Directory&gt;</pre>
90 </div>
91
92     <div class="example"><h3>Adding an input filter </h3><pre class="prettyprint lang-config"># In the following example, the sed filter will change the string
93 # "monday" to "MON" and the string "sunday" to SUN in the POST data
94 # sent to PHP.
95 &lt;Directory "/var/www/docs/sed"&gt;
96     AddInputFilter Sed php
97     InputSed "s/monday/MON/g"
98     InputSed "s/sunday/SUN/g"
99 &lt;/Directory&gt;</pre>
100 </div>
101 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
102 <div class="section">
103 <h2><a name="sed_commands" id="sed_commands">Sed Commands</a></h2>
104     <p>
105     Complete details of the <code>sed</code> command can be found from the
106    <a href="http://www.gnu.org/software/sed/manual/sed.txt">sed manual
107 page</a>.
108     </p>
109     <dl>
110         <dt><code>b</code></dt>
111         <dd>Branch to the label specified (similar to goto).</dd>
112         <dt><code>h</code></dt>
113         <dd>Copy the current line to the hold buffer.</dd>
114         <dt><code>H</code></dt>
115         <dd>Append the current line to the hold buffer.</dd>
116         <dt><code>g</code></dt>
117         <dd>Copy the hold buffer to the current line.</dd>
118         <dt><code>G</code></dt>
119         <dd>Append the hold buffer to the current line.</dd>
120         <dt><code>x</code></dt>
121         <dd>Swap the contents of the hold buffer and the current line.</dd>
122     </dl>
123 </div>
124 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
125 <div class="directive-section"><h2><a name="InputSed" id="InputSed">InputSed</a> <a name="inputsed" id="inputsed">Directive</a></h2>
126 <table class="directive">
127 <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>
128 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>InputSed <var>sed-command</var></code></td></tr>
129 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
130 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
131 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
132 </table>
133     <p>The <code class="directive">InputSed</code> directive specifies the <code>sed</code> command
134     to execute on the request data e.g., <code>POST</code> data.
135     </p>
136
137 </div>
138 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
139 <div class="directive-section"><h2><a name="OutputSed" id="OutputSed">OutputSed</a> <a name="outputsed" id="outputsed">Directive</a></h2>
140 <table class="directive">
141 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sed command for filtering response content</td></tr>
142 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>OutputSed <var>sed-command</var></code></td></tr>
143 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
144 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
145 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
146 </table>
147     <p>The <code class="directive">OutputSed</code> directive specifies the <code>sed</code>
148     command to execute on the response.
149     </p>
150
151 </div>
152 </div>
153 <div class="bottomlang">
154 <p><span>Available Languages: </span><a href="../en/mod/mod_sed.html" title="English">&nbsp;en&nbsp;</a> |
155 <a href="../fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
156 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
157 <script type="text/javascript"><!--//--><![CDATA[//><!--
158 var comments_shortname = 'httpd';
159 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_sed.html';
160 (function(w, d) {
161     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
162         d.write('<div id="comments_thread"><\/div>');
163         var s = d.createElement('script');
164         s.type = 'text/javascript';
165         s.async = true;
166         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
167         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
168     }
169     else {
170         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
171     }
172 })(window, document);
173 //--><!]]></script></div><div id="footer">
174 <p class="apache">Copyright 2017 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>
175 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
176 if (typeof(prettyPrint) !== 'undefined') {
177     prettyPrint();
178 }
179 //--><!]]></script>
180 </body></html>