I have been playing with sed for a while. Some interesting stuff,<br>Here: <a href="http://www.tutorialspoint.com/unix/unix-regular-expressions.htm">http://www.tutorialspoint.com/unix/unix-regular-expressions.htm</a><br>And here: <a href="http://sed.sourceforge.net/sed1line.txt">http://sed.sourceforge.net/sed1line.txt</a><br>
<br>However I am trying to remove from a log file (which is to be sent in an email) all repeat occurrences of lines starting with &quot;error:&quot;. So the log file looks like this:<br>====================================================================<br>
<span style="font-family:courier new,monospace">some information: blable</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">This was happening: blah blah</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">error: something went wrong</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">error: I&#39;m not happy</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">error: something went wrong</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">error: something went wrong</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">error: something went wrong</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">error: something went wrong</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">error: I&#39;m not happy</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">error: I&#39;m not happy</span><br style="font-family:courier new,monospace">
<br>====================================================================<br><br>Now I can use sed happily as:<br><span style="font-family:courier new,monospace">sed -e &#39;/error:/d&#39;</span><br><br>This removes <b>all</b> error messages (In some cases the script throws so many errors that to include them makes for a nasty email) What I can&#39;t find is how to remove all but the first. I&#39;m only interested in the first error as in most cases all others will span from that. Does anyone know how to do this? Or am I now using the wrong tool for the job?<br>
<br>More Ideal would be to include only one instance of the unique error messages but I believe that will be a little more complicated and more time than it is worth (not to mention that a more complicated solution is harder to explain to people I&#39;m working with).<br>