File cleaning

HI ,

I am getting the source data as below.


Source Data

CDR_Data,,,,,

F1,F2,F3,F4,F5,F6
5,5,6,7,8,7
6,6,g,,,
7,7,76,,,
8,8,gt,,,
9,9,df ,d,d,d


,,,,,
Logic for CDR Records,,,,,
<Indicate the Records Flag>,,,,,
,,,,,
,, Load,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,

,,,,,
,, Load Status,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,

How can I clean this to the below format., I tried using awk but I am not getting the desired output., what can i use to get the target data as below from the source files

Target Data

5,5,6,7,8,7
6,6,g,,,
7,7,76,,,
8,8,gt,,,
9,9,df ,d,d,d

Regards,
Wang

Hi wangkc,

Try:

$ cat infile
CDR_Data,,,,,

F1,F2,F3,F4,F5,F6
5,5,6,7,8,7
6,6,g,,,
7,7,76,,,
8,8,gt,,,
9,9,df ,d,d,d


,,,,,
Logic for CDR Records,,,,,
<Indicate the Records Flag>,,,,,
,,,,,
,, Load,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,
,Data files loaded at hourly basis.,,,
,,,,,
,,Data files loaded at hourly basis.,,,
,,,,,

,,,,,
,, Load Status,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
$ sed -ne '/^[0-9]/p' infile
5,5,6,7,8,7
6,6,g,,,
7,7,76,,,
8,8,gt,,,
9,9,df ,d,d,d
1 Like
grep ^[0-9] input_file

--ahamed

1 Like

Thanks both of you , Can you pls explain me what it is doing

 sed -ne '/^[0-9]/p' infile

it will print the lines which starts with a number ...
one more in awk ..

$  awk '/^[0-9]/ {print $0}' infile
1 Like