help with awk for file combination

1)file1:

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) |
|  ^  | mmap_bandwidth |
|  ^  | mmap_read bandwidth |       
|  ^  | memory write bandwidth |
|  Local Communication Latencies |  Pipe Latency |

2)file2

        
        422.6903
        1948.9000
        627.6130
        1029.1347
        10.6010
 

3)file3

        394.1523
        1880.2333
        598.7320
        1122.3873
        10.7973

I want to get file like below

   
| *Local Communication Bandwidths (MB/Sec)<br>(Bigger is better) | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75% |
| ^ | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52% |
| ^ | mmap_read bandwidth | 627.6130 | 598.7320 | native | 4.60% |
| ^ | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06% |
| Local Communication Latencies (us)<br>(Smaller is better) | Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85% |
 
 

NOTE: it is deived by '|' , I give the rule here, for example the last row formula is (422.6903 - 394.1523)/422.6903 percent, and if 422.6903 > 394.1523 then then it marked as "native" or else it is marked as "no_native"

nawk -f ya.awk file2.txt file3.txt file1.txt
ya.awk:

BEGIN {
  OFS=" | "
}
FILENAME == ARGV[1] {
  f1[FNR]=$NF
  next
}
FILENAME == ARGV[2] {
  f2[FNR]=$NF
  next
}
FILENAME == ARGV[3] {
  printf("%s %s%s%s%s%s%s%.2f%\n", $0, f1[FNR],OFS, f2[FNR], OFS,(f1[FNR] > f2[FNR])?"native":"no_native", OFS,((f1[FNR] - f2[FNR])/f1[FNR])*100)
}

Thanks. but it miss the last " |"

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75%
|  ^  | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52%
|  ^  | mmap_read bandwidth |        627.6130 | 598.7320 | native | 4.60%
|  ^  | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06%
|  Local Communication Latencies |  Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85%
 

I want it looks like

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75% |
|  ^  | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52% |
|  ^  | mmap_read bandwidth |        627.6130 | 598.7320 | native | 4.60% |
|  ^  | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06% |
|  Local Communication Latencies |  Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85% |
 
printf("%s %s%s%s%s%s%s%.2f%%s\n", $0, f1[FNR],OFS, f2[FNR], OFS,(f1[FNR] > f2[FNR])?"native":"no_native", OFS,((f1[FNR] - f2[FNR])/f1[FNR])*100, OFS)

Another approach:

awk '
FILENAME=="file2"{$1=$1;a[FNR]=$0;next}
FILENAME=="file3"{$1=$1;b[FNR]=$0;next}
{printf("%s %0.4f | %0.4f | %s | %0.2f% |\n", $0, a[++k], b[k],a[k]-b[k]>0?"native":"no_native" ,(a[k]-b[k])/a[k]*100)}
' file2 file3 file1

Thanks again. but I got:

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75%s
|  ^  | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52%s
|  ^  | mmap_read bandwidth |        627.6130 | 598.7320 | native | 4.60%s
|  ^  | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06%s
|  Local Communication Latencies |  Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85%s
 

if I want to add a row for file4 eg:

file4:

abc fef
ded blash
....
qq
fdfdfdsfsfsdf fdfds

to get

 
| *Local Communication Bandwidths (MB/Sec) | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75% | abc fef |
| ^ | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52% | ded blash |
| ^ | mmap_read bandwidth | 627.6130 | 598.7320 | native | 4.60% | .... |
| ^ | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06 | qq |
| Local Communication Latencies | Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85 | fdfdfdsfsfsdf fdfds |
 

how could do it?

sorry again.....

BEGIN {
  OFS=" | "
  pct=sprintf("%c", 037)
}
FILENAME == ARGV[1] {
  f1[FNR]=$NF
  next
}
FILENAME == ARGV[2] {
  f2[FNR]=$NF
  next
}
FILENAME == ARGV[3] {
  printf("%s %s%s%s%s%s%s%.2f%c%s\n", $0, f1[FNR],OFS, f2[FNR], OFS,(f1[FNR] > f2[FNR])?"native":"no_native", OFS,((f1[FNR] - f2[FNR])/f1[FNR])*100, pct, OFS)
}

to add another file:
nawk -f ya.awk file2.txt file3.txt file4.txt file1.txt

BEGIN {
  OFS=" | "
  pct=sprintf("%c", 037)
}
FILENAME == ARGV[1] {
  f1[FNR]=$NF
  next
}
FILENAME == ARGV[2] {
  f2[FNR]=$NF
  next
}
FILENAME == ARGV[3]
   f3[FNR]=$NF
   next
}
FILENAME == ARGV[4] {
  printf("%s %s%s%s%s%s%s%.2f%s%s%s%s\n", $0, f1[FNR],OFS, f2[FNR], OFS,(f1[FNR] > f2[FNR])?"native":"no_native", OFS,((f1[FNR] - f2[FNR])/f1[FNR])*100,pct, OFS, f3[FNR], OFS)
}

I got

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75 | 
|  ^  | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52 | 
|  ^  | mmap_read bandwidth |        627.6130 | 598.7320 | native | 4.60 | 
|  ^  | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06 | 
|  Local Communication Latencies |  Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85 | 

it should be percent for the last row like we do in the firest time :slight_smile:

I get:

|  *Local Communication Bandwidths (MB/Sec)  | Memory copy (bcopy) | 422.6903 | 394.1523 | native | 6.75% |
|  ^  | mmap_bandwidth | 1948.9000 | 1880.2333 | native | 3.52% |
|  ^  | mmap_read bandwidth |        627.6130 | 598.7320 | native | 4.60% |
|  ^  | memory write bandwidth | 1029.1347 | 1122.3873 | no_native | -9.06% |
|  Local Communication Latencies |  Pipe Latency | 10.6010 | 10.7973 | no_native | -1.85% |