Using sed to modify Apache ports file
<p>I am trying to edit <code>Listen 80</code> in ports.conf file with sed.</p>

<p>Since that file looks like :</p>

<pre><code>Listen 80

&lt;IfModule ssl_module&gt;
    Listen 443
&lt;/IfModule&gt;

&lt;IfModule mod_gnutls.c&gt;
    Listen 443
&lt;/IfModule&gt;
</code></pre>

<p>with this command:
head -n1 sed_test | sed -i -e 's/Listen [0-9]+/Listen 80/1p' sed_test</p>

<p>It changes all 'Listen $port_number' in the file. I guess it is because in second command I specify a file. </p>

<p>If I don't specify, to which file it should write, I get an error
<code>sed: no input files</code> which is logical although.</p>

<p>I know that it can be done only with a sed, but I am unsure how to edit only one line and replace it with my custom value.</p>

<p>So this is what I want to accomplish:</p>

<p><strong>sed -i -e <em>some_command/Listen 8080</em> file</strong></p>

<p><strong>cat file</strong> -> </p>

<pre><code> Listen 8080

    &lt;IfModule ssl_module&gt;
        Listen 443
    &lt;/IfModule&gt;

    &lt;IfModule mod_gnutls.c&gt;
        Listen 443
    &lt;/IfModule&gt;
</code></pre>

<p>How to do that?</p>