Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to join 3 files on a column which has sorted unique numeric values (those files have only one column of values though) and starts with same prefix for an example "usi".

Now, while I am doing this

join -j 1 ../Test_Data/usi* > ../Test_Data/join_output.txt

I am finding following error:

join: extra operand `usi_rtree_lw_100000.txt'
Try `join --help' for more information.

Any ideas?

share|improve this question
add comment

1 Answer

join accepts only 2 files to join. To operate on 3 file you have to use 2 join calls:

join -j 1 <(join -j 1 ../Test_Data/usi-1 ../Test_Data/usi-2) ../Test_Data/usi-3 > ../Test_Data/join_output.txt

The above command requires bash, as uses process substitution. If you use another shell, please specify which.

Update according to the comment.
If you know only a file name pattern instead of exact file names, let the shell expand the pattern, capture the expanded list in an array then use the array elements as parameters:

file=(../Test_Data/usi*)
join -j 1 <(join -j 1 "${file[0]}" "${file[1]}") "${file[2]}"
share|improve this answer
    
actually the problem is , I know only the prefixes of the files,I cant use the exact names of them. –  MiNdFrEaK Oct 22 '12 at 7:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.