Re: join two files
Jim Hill <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 05/15/2013 11:51 PM, MOKRANI Rachid wrote:> Hi,
>
> Well this is a good solution and it work. You should send it to the
> list so that others can benefit too.
ok, happy to.
awk -vFS=\; -vOFS=\; '{ printf("%04d;%s\n",$1,$0) }' file1>@file1
awk -vFS=\; -vOFS=\; '{ printf("%04d;%s\n",$1,$0) }' file2>@file2
join -a1 -t\; -o 1.2,1.3,2.3 -eN/A @file2 @file1
So
- Therry Blanc's sed solution actually delivers what was requested, but
I have to wonder if the O(NM) wouldn't start mattering even on today's
hardware.
- Ruud H.G. van Tol's perl ... kinda shows perl's strengths, don't it?
and it's O(lgN M),
- and this one's linear and probably easier on the uninitiated, but
you'd have to tweak it to avoid multiple passes.
The O()'s are casual estimates, and unless this is for really
industrial-strength data volumes or overeager optimizers like me I can't
see them mattering much.