0

I have one file which contains several lines of data

editPin -pin phy_inst/i_dfi_row_cmd_p1_d[0] ctrl_soft_phy_inst/hbm_ch_tile_4_hbm_tile_inst/o_phy_row_cmd_p1[0] -assign {1443.0305 184.62} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID
editPin -pin phy_inst/i_dfi_row_cmd_p1_d[1] ctrl_soft_phy_inst/hbm_ch_tile_4_hbm_tile_inst/o_phy_row_cmd_p1[0] -assign {1444.0305 185.62} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID

and i want to perform some operation and i want to set my line like this

eval editPin -pin i_dfi_row_cmd_p1_d[0]  -assign { 0 [ expr 1443.0305 184.62]} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID
eval editPin -pin i_dfi_row_cmd_p1_d[1]  -assign { 0 [ expr 1444.0305 185.62]} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID

I used these commands individually, I tried them, and it worked how I wanted the structure.

awk '{$4=""; print $0}' all_pin 
awk '{print "eval " $0}' all_pin 
sed -e /^editPin/'{ s#phy_inst/## ; s/{/{ 0 [ expr / ; s/}/]}/ ; }' all_pin

but when i used these commands together its not giving the result how i want

cat all_pin | awk '{$4=""; print $0}' all_pin | awk '{print "eval " $0}' all_pin | sed -e /^editPin/'{ s#phy_inst/## ; s/{/{ 0 [ expr / ; s/}/]}/ ; }' all_pin

may i know the solution for this

and i want to perform addition operation for this block

-assign { 0 [ expr 1443.0305 362.764+X]}

X is a constant value and i want to add X to 362.764 using command.I tried but I got the wrong answer

awk '{print $10+100}' all_pin

please help me to get out of this

The solution what i have is

awk -v X=10000 -f SE.awk all_pin

###  SE.awk ###
 {  for(i=1; i<=NF ; i++ ) {
        if ( $i ~ /^phy_inst/ ) {
                $i=substr($i,10) ;
                $(i+1)="" ; }
        if ( $i == "-assign" ) {
                $(i+1)="{ 0 [ expr " $(i+1) ;
                $(i+2)=$(i+2) + X " ]}" ;
                }
 }
        $1 = "eval " $1 ;
         print ;
 }

but i am trying to write individual commands using multiple awk and sed commands please guide me with the best commands to remove phy_inst/* from the line and to perform an arithmetic operation for -assign { 0 [ expr 1444.0305 185.62]} line

to remove phy_inst/* i tried this command

awk -F 'editPin/ ' '{print substr($3,10) $0}' all_pin

perform arithmetic operations i have no idea please guide me for this

1 Answer 1

0

Your endless pipe doesn't work that way; you're not modifying your file but always work on the original file, and your results are being discarded.

Given your input has always the same, given above structure, try awk in one go:

awk -v X=10000 '
        {$7 += X
         $7 =  $7 "]}"
         $6 =  "{ 0 [ expr " substr($6,2)
         $4 =  ""
         sub(/phy_inst\//,"")
         print "eval " $0
        }
' CONVFMT="%8.2f" file
eval editPin -pin i_dfi_row_cmd_p1_d[0]  -assign { 0 [ expr 1443.0305 10184.62]} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID
eval editPin -pin i_dfi_row_cmd_p1_d[1]  -assign { 0 [ expr 1444.0305 10185.62]} -layer M10 -pinWidth 0.038 -pinDepth 0.395 -fixOverlap false -fixedPin -snap MGRID

It operates on the individual fields as desired, adds the X value to the seventh field, appends the "]}", and then prints out the result with the leading "eval".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .