Hola Greetings Experts ,
I have records spreaded across multiple lines. in attached log.txt i want output to be in 1 line like this below Atached as Output.txt.
In brief
Output related to 1 line is spreaded across multiple row I wanted it to be in 1 row .
Please opem the file in notepad as I have modified as per output Is required
EXPERTS PLEASE HELP !!!!
RudiC
2
Don't use notepad to edit unix files - it will destroy your file format/output. I had to remove the <CR> chars before the sed
command worked!
Take this as a starting point to refine yourself:
$ sed -n 'H; /Procedure Name/ {x;s:\n:,:g;p}; $ {x;s:\n:,:g;p}' Log.txt
,------------------------------------------------------------,,Procedure Name: 302_ALLDATA
Procedure Name: 302_ALLDATA,, Procedure Type: dowdow, Active: yes, Effective date: 09/22/2007 10:09:16, Jok
Procedure Name: 302_alibaba,, Procedure Type: dowdow, Active: yes, Effective date: 09/22/2007 10:09:16, Jok
Procedure Name: 302_alibaba_1,, Procedure Type: dowdow, Active: yes, Effective date: 09/22/2007 10:09:16, J
Procedure Name: 302_Profiles,, Procedure Type: dowdow, Active: yes, Effective date: 09/22/2007 10:09:16, Jo
For the first line, you have to either modify your input file, or add sth like 1,2d;
to the sed
command, or use sth like tail
to eliminate.
Thanks alot RudiC for a try but looks like it did not worked for me see below : the output is spreading across multiple lines
sed -n 'H; /Procedure Name/ {x;s:\n:,:g;p}; $ {x;s:\n:,:g;p}' Log |more
,Procedure Name: 302_ALLDATA---------------------------
, Granular Rasbhariiiitributes: (none defined)
, Checksum Change Detection: okarityaan_Controlling\hurrah202-dastaan_Controlling
, Residence: (spe months)ynday 10:50:00dure))
, Friday 19:00:00 --> Monday 10:00:00dure)
, Thursday 20:00:00 --> Thursday 06:00:00dure))
,Procedure Name: 302_alibaba---------------------------
, Granular Rasbhand attributes: (none defined)1
, \\Emotional\alibaba\n*.*T dalda
, Retention Level: 9 (infinity)y
, Volume Pool: (same as Proceage unit not required)
, Type: when then Jokaray 10:00:00dure)
,-----------------------------------------y 06:00:00dure))
,Procedure Name: 302_alibaba_1
, Granular Rasn and attributes: (none defined)1
, Dailyi indexing: 0d(same as specified for Procedure))
, EXCLUDE DATE 3 - 09/25/2008as specified for
RudiC
4
Please use code tags as required by forum rules!
What about the Windows (!) control chars like ^M
?
sed -n 'H; /Procedure Name/ {x;s:\n:,:g;p}; $ {x;s:\n:,:g;p}' Log|more
,Procedure Name: 302_ALLDATA---------------------------
, Granular Rasbhariiiitributes: (none defined)
, Checksum Change Detection: okarityaan_Controlling\hurrah202-dastaan_Controlling
, Residence: (spe months)ynday 10:50:00dure))
, Friday 19:00:00 --> Monday 10:00:00dure)
, Thursday 20:00:00 --> Thursday 06:00:00dure))
,Procedure Name: 302_alibaba---------------------------
, Granular Rasbhand attributes: (none defined)1
, \\Emotional\alibaba\n*.*T dalda
, Retention Level: 9 (infinity)y
, Volume Pool: (same as Proceage unit not required)
, Type: when then Jokaray 10:00:00dure)
,-----------------------------------------y 06:00:00dure))
,Procedure Name: 302_alibaba_1
, Granular Rasn and attributes: (none defined)1
, Dailyi indexing: 0d(same as specified for Procedure))
, EXCLUDE DATE 3 - 09/25/2008as specified for Procedure))
, Volumence: (specific storage unit not required)
,Procedure Name: 302_Profiles--------------------------
, Data Procedureification: -fied)ot-tld-1