Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare two column values

Status
Not open for further replies.

mikawin

Technical User
Apr 15, 2009
28
0
0
US
Hello,

I have three columns with data (shown with space delimiter) that look like:

Col1 Col2 Col3
--------------
x y y=6/x=7
a b a=9/b=4
p q p=6/q=8
r s s=6/r=4

I want to pick the high value for each row and have it output to the 4th column with information as to which Col has the high value. For the above example it would be

Col1 Col2 Col3 Col4
--------------------
x y x=6/y=7 Col2_high
a b a=9/b=4 Col1_high
p q p=6/q=8 Col2_high
r s s=6/r=4 Col2_high

Thanks!
Mika
 
Personally I would use awk for a simple one like that, but perl will serve you equally well. What have you tried so far?

Annihilannic.
 
Well, I split the Col3 field and first did the number comparison and then compared the letters with the two columns. This works, but it seems too convoluted. Hence the question to the forums.

Thx,
Mika
 
Post your code and then we can offer some constructive criticism. :)

Annihilannic.
 
No worries, used a hash and cut the code.

Thx,
Mika
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top