Sample Header Ad - 728x90

How to sort and join at the same time?

4 votes
3 answers
5479 views
I have 2 files, one having 2 columns, another having 1 column. The second file is sorted using sort -u. Now the task is I need to join this column with the first column of the first file, which is not sorted. So what will be the syntax? Will join -j 1 file2.txt sort -s -n -k 1 file1.txt work? The output I want is actually the 2nd column of file 2 after joining and the unique entries in it. File 2 ------ 1 2 3 File 1 ------ 2 500 1 5000 1 300 3 3000 3 300 4 450 Output ------ 5000 300 500 3000
Asked by N. F. (2269 rep)
Sep 28, 2012, 08:19 AM
Last activity: Aug 31, 2024, 04:45 AM