coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Paste more than two files


From: Pádraig Brady
Subject: Re: Paste more than two files
Date: Sun, 12 Feb 2012 10:40:59 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 02/12/2012 02:36 AM, address@hidden wrote:
> Hi Coreutils,
> 
> I posted to the list about a month ago and haven't gotten any
> response. Perhaps it got overlooked because of the holidays (or
> post-holiday email glut), so I'm reposting it:
> 
> ---
> 
> Hello,
> 
> I fairly recently discovered the joys of join, but now I wonder why it
> is limited to two files?
> 
> In other words, I would like to do the following:
> 
> join file1 file2 ... fileN
> 
> While I CAN achieve this through other methods, they are not ideal.
> For instance, paste works with multiple files, but then I must cut out
> the repeated key columns. The following also works, but doesn't
> generalize to filename expansions (e.g. `join file*`):
> 
> join file1 file2 | join - file3 | ... | join - fileN
> 
> As for my use case, I am working with data files containing the
> results of multiple systems running over the same test items. I would
> like to compare the results of all systems for each item by putting
> them side-by-side.
> 
> I don't know the history of the command, so I am not aware of any
> technical or ideological reasons why it shouldn't support more than
> two files. Any explanation appreciated!

Sorry I missed your previous mail.

Well a join operation is not scalable across many files.
You'd have to stream from each file (hence keep file
descriptors open), and maintain internal comparison buffers
for each file. Hence join is restricted to 2 "tables",
which can be combined more generally as you've shown above.

Note for many files, and to handle globbing,
you might want to use temp files, which would
also help with scalability, like:

base=$(mktemp)
cp base $base
for file in file*; do
   nbase=$(mktemp)
  join $base $file > $nbase
  rm $base
done
cat $nbase
rm $nbase

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]