Page 1 of 1

concatenate to previous line

Posted: Fri Jan 25, 2013 2:59 am
by C0ppert0p
I have a need to concatenate lines matching a pattern to be concatenated with the preceding line.
Example:

INPUT

Description: Process STORE.EXE (PID=3364).
(Server name | Roles | Enabled | Reachability.........
In-site:
servername1.local CDG 1 7 6 1 0 1 1 1 2
servername2.local CDG 1 7 7 1 0 1 1 7 1


OUTPUT

Description: Process STORE.EXE (PID=3364). (Server name | Roles | Enabled | Reachability.........
In-site:servername1.local CDG 1 7 6 1 0 1 1 1 2 servername2.local CDG 1 7 7 1 0 1 1 7 1


The issue I have is that the PID=3364 varies; the CDG value varies and not all lines starting with, "Description", end with a PID.
However any line starting with Servername 2.local CDG should be concatenated with the previous line.
And, and line beginning with, "(Server name" should be concatenated with the previous line.

I have thousands of these records so doing it manually is out of the question

Posted: Fri Jan 25, 2013 6:17 am
by MudGuard
Replace (Regular Expressions checked, Posix Syntax selected):

\n\(Server
by
\(Server


and in a second step:
\nservername
by
servername

(If you want a space before the (Servername or servername, add it to the beginning of the replace by value)

Posted: Fri Jan 25, 2013 10:11 pm
by C0ppert0p
That was the solution I was hoping for.
Cheers!