I have two big files. file1 has data in below format
place u_RX_WR_SE1_LS { } R0 -place
place u_bank_LS { } R0 -place
file2 has data in below format
set inst RX_WR_SE1_PD ; add -inst $inst -cell PR ; place $inst 5.76 5305.84 0
set inst RX_WR_SE2_PD ; add -inst $inst -cell PR ; place $inst 5.76 5338.864 0
set inst bank_PD ; add -inst $inst -cell PR ; place $inst 5.76 5371.888 0
I want to search 2nd field removing starting u_
and _LS
from file1 i.e RX_WR_SE1
in file2, and if found in file2, for same match line copy field $13 $14
from file2 and add it inside { }
in file1.
The output should be in below format.
place u_RX_WR_SE1_LS { 5.76 5305.84 } R0 -place
place u_bank_LS { 5.76 5371.888 } R0 -place
Anyone who can help using TCL or SHELL? In shell I tried
awk 'FNR==NR{gsub(/u_|_LS/,"",$2);arr[$2]="";next}
{
for (i in arr) { if ($0 ~ i) {print i,$13,$14}}
}
' file1 file2
but this is not giving proper results .
In TCL it is also fine.