URGENT: sed or awk help
Posted on 2005-04-26
I need a simple thing done, and while I'm sure sed and/or awk would be the proper tool, I really don't know how to use them yet.
I have a DOS text file that has extraneous CR/LF sequences that I want removed. This is an application log file, and these extra CR/LF sequences break up log entries into two lines.
The current file looks like this:
00:11:22 app node activity description starts here and then<CR><LF>
there's a static number of spaces and then the rest of the entry followed by a "normal" <CR><LF>
00:11:23 app node next log entry starts here, and I want to keep the *second* <CR><LF>
from the previous entry <CR><LF>
...and so forth
This is complicated by lines that are NOT broken in this fashion.
So, I need a sed or awk (or if there's a better tool, I'm listening) script that will look for the <CR><LF> followed by a fixed number of spaces, and replace that sequence of bytes with just a single space. A <CR><LF> sequence followed by a number would be ignored (left intact).
I'm looking for something I can run from the command-line, using re-direction symbols is fine.