The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-06-2008
vasanth.vadalur vasanth.vadalur is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 24
not sorting, search and to do arithmetic..

Hi thanks,

But my question is not like sorting.

I am explaining little detaily:

FIle 1:

123 678 345 hi 6798
452 789 256 bi 8746
145 689 124 ji 435
456 690 345 ki 789

File 2:
345
256
124

Expected Output:

The outfile should rearrange according to the fourth column of file1, matching with the first column of file2.

Like:

123 678 345 hi 6798
456 690 345 ki 789
452 789 256 bi 8746
145 689 124 ji 435

Then the column 5 should be added for 345 matching individuallly, 256 invidually, 124 individually.

Like:
the addition of 345 match 5th column is 6798+789 = 7587
the addition of 256 macth 5th column is 8746
the addition of 124 match 5th column is 435

Thanks in advance for your reply,
Vasanth



Quote:
Originally Posted by era View Post
If the number is always in the fourth column and
all you need is to sort numerically, you don't need Perl at all.

Code:
sort -rn -k4 file2
What's with the poll?