need help on awk script 
Author Message
 need help on awk script

Hi,

I have a file pasted below
#1
0x0000.00380eef
#2
0x0000.00379eee
#3
0x0000.00379eee
#4
0x0000.00379eee
#5
0x0000.00379eee
#6
0x0000.00379eee
#7
0x0000.00379eee
#8
0x0000.00379eee
#9
0x0000.00379eee
#10
0x0000.00379eee
#11
0x0000.00379eee  

The first record is the file# and the second record is a hexadecimal
number and so on. There are 11 such combinations. I want to find the
max hexadecimal number and then find the file which has a hexadecimal
number which doesnt match this max value

Any help would be deeply appreciated

Thanks and regds
Fairlie Rego



Tue, 10 Aug 2004 18:42:05 GMT  
 need help on awk script

Quote:

> I have a file pasted below
> #1
> 0x0000.00380eef
> #2
> 0x0000.00379eee
> #3
> 0x0000.00379eee

[clip]

Quote:
> The first record is the file# and the second record is a hexadecimal
> number and so on. There are 11 such combinations. I want to find the
> max hexadecimal number and then find the file which has a hexadecimal
> number which doesnt match this max value

So in the example data you want to get all files except #1?
Can we assume the hex numbers are all of the same length
(so we can compare them as strings)?
Then:

awk '/#/{file=$0; getline; hex[file]=$0; if ($0 > maxhex) maxhex=$0 }
     END { for (f in hex) { if (hex[f] != maxhex) print f, hex[f] } }' file

--
Tapani Tarvainen



Tue, 10 Aug 2004 19:00:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help with awk script

2. I need help with AWK Script?! any 1?

3. Need little help with a awk script

4. Need help to write a simple awk script

5. Need help with simple awk script

6. Help optimising AWK script

7. Help with A simple awk script.

8. Script Help with awk

9. help for newbie: way to get the value of an awk variable in a shell script

10. Help with awk script

11. awk script help

12. Help passing command line parameters to awk scripts

 

 
Powered by phpBB® Forum Software