Search code examples
linuxshellscriptingawr

Listing strings from file using awr Linux Red Hat


I have a file "salida_test" containing (in repetitive way):

Point ID   1.750251
 Point Name >BRI_4L_SA2__INT Interruptor 33kV Parque Industrial              <
 value 2
 Time of last value update   (ascii): >03/07/17 11:11:14.596 ART<
 TLQ   0000000c00004000
 station #79    abbr: >BRI         <  full: >E.T. BRIGADIER LOPEZ            <

 Point ID   1.140147
 Point Name >RUF_5BC1____INT Int. Banco Cap. 1 13.2kV                        <
 value 2
 Time of last value update   (ascii): >03/07/17 10:27:58.495 ART<
 TLQ   0000000c00800000
 station #18    abbr: >RUF         <  full: >E.T. RUFINO   

              <

I need extract just the lines, in this format:

Point ID   1.750251  value 2    --> in the same line
Point ID   1.140147  value 2    --> in the same line

and then, filtering again:

750251 2
140147 2

I have a partial filter, but I can´t to obtain the solution:

awk '(/Point ID/ || /hi/)' salida_test

shows:

 Point ID   1.750251
 Point ID   1.140147

and:

awk '(/value/ || /hi/) && !/Time of last value/' salida_test

shows:

value 2
value 2

Could you give me a posible resolution?


Solution

  • try:

    awk '/Point ID/{sub(/.*\./,"",$3);VAL=$3;next} /^value/{print VAL,$2}'  Input_file
    

    Explanation: Looking for line which has string "point ID" in it then substituting 3rd field of it till DOT and saving it to variable named VAL then, use of next will skip all further statements of awk. Now ^Value will check a line/record which starts from it, if yes then it will simply print variable VAL's value with 2nd field value of it too.