AWK or SED solution

Hello. I have big file data like this(part of file):

....
18210102021010000110 47401000000
021001 5166891.16
021011 5166891.16
18210602010020000110 47401000000
020701 8995421.00
021001 8995421.00
021011 8995421.00
030801 .08
18210604011020000110 47401000000
020701 9048.00
021001 36217.00
021011 36217.00
030801 27382.00
18211603010010000140 47401000000
......

I need AWK or SED solution to get like this:

....
18210102021010000110 47401000000 021001 5166891.16
18210102021010000110 47401000000 021011 5166891.16
18210602010020000110 47401000000 020701 8995421.00
18210602010020000110 47401000000 021001 8995421.00
18210602010020000110 47401000000 021011 8995421.00
18210602010020000110 47401000000 030801 .08
18210604011020000110 47401000000 020701 9048.00
18210604011020000110 47401000000 021001 36217.00
18210604011020000110 47401000000 021011 36217.00
18210604011020000110 47401000000 030801 27382.00
18211603010010000140 47401000000
....

Try this...

awk '/^182/{p=$0;next}$0=p$0' input_file

or

awk '{if(length($1)>=20){p=$0;next}}$0=p$0' input_file

--ahamed

1 Like

ahamed101, man, you are the best! Thanks!

but can you give me little fix? There is no space between second and third columns:

18210101012020000110 47401000000021012 3292253.00
18210101012020000110 47401000000021301 3459101.69
18210101012020000110 47401000000030801 847548.10
18210101012020000110 47401000000030802 134949.93
awk '{if(length($1)>=20){p=$0;next}}{print p,$0}' input_file

#or

awk '/^182/{p=$0;next}{print p,$0}' input_file

--ahamed

1 Like