title: sed search and replace with 2 conditions/patterns
body: <p>I have a file:</p>
  <pre><code>&lt;a href=&quot;http://www.gnu.org/software/coreutils/&quot;&gt;http://www.gnu.org/software/coreutils/&lt;/a&gt;
  &lt;a href=&quot;../../3/glob.html&quot; rel=&quot;nofollow&quot;&gt;glob&lt;/a&gt;
  &lt;a href=&quot;lxc-ls.html&quot; rel=&quot;nofollow&quot;&gt;lxc-ls&lt;/a&gt;
  </code></pre>
  <p>I need to only replace below:</p>
  <pre><code>&lt;a href=&quot;lxc-ls.html&quot; rel=&quot;nofollow&quot;&gt;lxc-ls&lt;/a&gt;
  </code></pre>
  <p>with</p>
  <pre><code>&lt;a href=&quot;../lxc-ls.html&quot; rel=&quot;nofollow&quot;&gt;lxc-ls&lt;/a&gt;
  </code></pre>
  <p><strong>lxc-ls</strong> can be any word as I have multiple such links in several files which I need to replace.</p>
  <p>I do not want to make any changes to the other 2 links. i.e.</p>
  <pre><code>&lt;a href=&quot;http://www.gnu.org/software/coreutils/&quot;&gt;http://www.gnu.org/software/coreutils/&lt;/a&gt;
  &lt;a href=&quot;../../3/glob.html&quot; rel=&quot;nofollow&quot;&gt;glob&lt;/a&gt;
  </code></pre>
  <p>What I have tried until is:</p>
  <pre><code>$ sed '/html/ i\
  ..' file
  
  </code></pre>
  <p>But this appends to the start of the line, also the other condition of excluding 2 URLs is also not full filled.</p>
  <p>Here is a more realistic example from one of the file.</p>
  <pre><code>&lt;b&gt;&lt;a href=&quot;../../1/echoping.html&quot; rel=&quot;nofollow&quot;&gt;echoping&lt;/a&gt;&lt;/b&gt;(1),
  &lt;b&gt;&lt;a href=&quot;../../3/getaddrinfo.html&quot; rel=&quot;nofollow&quot;&gt;getaddrinfo&lt;/a&gt;&lt;/b&gt;(3),
  &lt;b&gt;&lt;a href=&quot;../../3/getaddrinfo_a.html&quot; rel=&quot;nofollow&quot;&gt;getaddrinfo_a&lt;/a&gt;&lt;/b&gt;(3),
  &lt;b&gt;&lt;a href=&quot;../../2/getpeername.html&quot; rel=&quot;nofollow&quot;&gt;getpeername&lt;/a&gt;&lt;/b&gt;(2),
  &lt;b&gt;&lt;a href=&quot;../../2/getsockname.html&quot; rel=&quot;nofollow&quot;&gt;getsockname&lt;/a&gt;&lt;/b&gt;(2),
  &lt;b&gt;&lt;a href=&quot;../../3/ping_setopt.html&quot; rel=&quot;nofollow&quot;&gt;ping_setopt&lt;/a&gt;&lt;/b&gt;(3),
  &lt;b&gt;&lt;a href=&quot;../../5/proc.html&quot; rel=&quot;nofollow&quot;&gt;proc&lt;/a&gt;&lt;/b&gt;(5),
  &lt;b&gt;&lt;a href=&quot;rds.html&quot; rel=&quot;nofollow&quot;&gt;rds&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;../../2/recv.html&quot; rel=&quot;nofollow&quot;&gt;recv&lt;/a&gt;&lt;/b&gt;(2),
  &lt;b&gt;&lt;a href=&quot;rtnetlink.html&quot; rel=&quot;nofollow&quot;&gt;rtnetlink&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;sctp.html&quot; rel=&quot;nofollow&quot;&gt;sctp&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;../../3/sctp_connectx.html&quot; rel=&quot;nofollow&quot;&gt;sctp_connectx&lt;/a&gt;&lt;/b&gt;(3),
  &lt;b&gt;&lt;a href=&quot;../../2/send.html&quot; rel=&quot;nofollow&quot;&gt;send&lt;/a&gt;&lt;/b&gt;(2),
  &lt;b&gt;&lt;a href=&quot;udplite.html&quot; rel=&quot;nofollow&quot;&gt;udplite&lt;/a&gt;&lt;/b&gt;(7)
  &lt;a href=&quot;http://gnu.org/licenses/gpl.html&quot;&gt;http://gnu.org/licenses/gpl.html&lt;/a&gt;
  &lt;a href=&quot;http://translationproject.org/team/&quot;&gt;http://translationproject.org/team/&lt;/a&gt;
  </code></pre>
  <p>Here I only need to replace:</p>
  <pre><code>&lt;b&gt;&lt;a href=&quot;rds.html&quot; rel=&quot;nofollow&quot;&gt;rds&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;rtnetlink.html&quot; rel=&quot;nofollow&quot;&gt;rtnetlink&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;sctp.html&quot; rel=&quot;nofollow&quot;&gt;sctp&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;udplite.html&quot; rel=&quot;nofollow&quot;&gt;udplite&lt;/a&gt;&lt;/b&gt;(7)
  </code></pre>
  <p>with:</p>
  <pre><code>&lt;b&gt;&lt;a href=&quot;../rds.html&quot; rel=&quot;nofollow&quot;&gt;rds&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;../rtnetlink.html&quot; rel=&quot;nofollow&quot;&gt;rtnetlink&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;../sctp.html&quot; rel=&quot;nofollow&quot;&gt;sctp&lt;/a&gt;&lt;/b&gt;(7),
  &lt;b&gt;&lt;a href=&quot;../udplite.html&quot; rel=&quot;nofollow&quot;&gt;udplite&lt;/a&gt;&lt;/b&gt;(7)
  </code></pre>