+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Newbie level 5
    Points: 89, Level: 1

    Join Date
    Aug 2019
    Posts
    10
    Helped
    2 / 2
    Points
    89
    Level
    1

    Finding certain string in file using bash shell scriot

    I need to develop bash shell script extracting capacitance values of nets from post pnr spf file and put them in a column vector.
    The spf file is like following:

    Code - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    *|NET top33_dft_1/top33_orig_1/rf0_1/n503 0.008406PF
    *|I (top33_dft_1/top33_orig_1/rf0_1/U924:A1
    *+ top33_dft_1/top33_orig_1/rf0_1/U924 A1 I 0.002625PF 184.520 304.920)
    *|I (top33_dft_1/top33_orig_1/rf0_1/U918:A2
    *+ top33_dft_1/top33_orig_1/rf0_1/U918 A2 I 0.002814PF 189.000 289.240)
    ....
    *|NET top33_dft_1/top33_orig_1/wradd_hold/FE_OFN38_smc18_rf_wradd_hold_1_
    *+ 0.000132PF
    *|I (top33_dft_1/top33_orig_1/wradd_hold/FE_OFC37_smc18_rf_wradd_hold_1_:ZN
    *+ top33_dft_1/top33_orig_1/wradd_hold/FE_OFC37_smc18_rf_wradd_hold_1_ ZN 
    ....

    I need to capture only the value after net name, i.e. first value after "*|NET". How can I do it??
    Regards,
    Abdelrahman.

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 3
    Points: 7,460, Level: 20
    Achievements:
    7 years registered

    Join Date
    Jul 2010
    Location
    Sweden
    Posts
    997
    Helped
    383 / 383
    Points
    7,460
    Level
    20

    Re: Finding certain string in file using bash shell scriot

    This is a job for "sed" or "awk", but I think you should tell us the expected output from your example.
    Is the "*|NET" always on the same line as the value?


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 31,634, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,317
    Helped
    1719 / 1719
    Points
    31,634
    Level
    43

    Re: Finding certain string in file using bash shell scriot

    It also looks like the value may be on the next line which the line continuation is denoted by "*+". See lines 7 & 8.

    I think I would write a script with Python, Perl, Ruby, whatever than use command like sed/awk to do this. You can still call the script from a bash shell.



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 8,693, Level: 22

    Join Date
    Apr 2016
    Posts
    1,825
    Helped
    320 / 320
    Points
    8,693
    Level
    22

    Re: Finding certain string in file using bash shell scriot

    Quote Originally Posted by Abdo_Mgdy View Post
    I need to develop bash shell script extracting capacitance values of nets from post pnr spf file and put them in a column vector.
    The spf file is like following:

    Code - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    *|NET top33_dft_1/top33_orig_1/rf0_1/n503 0.008406PF
    *|I (top33_dft_1/top33_orig_1/rf0_1/U924:A1
    *+ top33_dft_1/top33_orig_1/rf0_1/U924 A1 I 0.002625PF 184.520 304.920)
    *|I (top33_dft_1/top33_orig_1/rf0_1/U918:A2
    *+ top33_dft_1/top33_orig_1/rf0_1/U918 A2 I 0.002814PF 189.000 289.240)
    ....
    *|NET top33_dft_1/top33_orig_1/wradd_hold/FE_OFN38_smc18_rf_wradd_hold_1_
    *+ 0.000132PF
    *|I (top33_dft_1/top33_orig_1/wradd_hold/FE_OFC37_smc18_rf_wradd_hold_1_:ZN
    *+ top33_dft_1/top33_orig_1/wradd_hold/FE_OFC37_smc18_rf_wradd_hold_1_ ZN 
    ....

    I need to capture only the value after net name, i.e. first value after "*|NET". How can I do it??
    Literally every programming language or scripting language can be used for parsing this. Use whatever you are more comfortable with. sed/awk look like good candidates here.
    Really, I am not Sam.



  5. #5
    Newbie level 5
    Points: 89, Level: 1

    Join Date
    Aug 2019
    Posts
    10
    Helped
    2 / 2
    Points
    89
    Level
    1

    Re: Finding certain string in file using bash shell scriot

    The output shoud be as follows:
    [syntax=txt]
    0.008406
    0.000132
    ...
    [\syntax]

    And, no the value does not always come in the same line
    Regards,
    Abdelrahman.



--[[ ]]--