0

Below is my input file:

PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:16:46.523.177, 2 PS Sensor Value = -5.501000 , Min = -5.583000 , Max = -5.319000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:16:46.523.210, 3 PS Sensor Value = 15.996000 , Min = 15.814000 , Max = 16.078000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:16:46.523.231, 4 PS Sensor Value = -16.505000 , Min = -16.587000 , Max = -16.323000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:16:46.523.263, 5 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:16:46.523.302, 6 PS Sensor Value = 4.002000 , Min = 3.820000 , Max = 4.084000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.481.557, 1 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.518.691, 2 PS Sensor Value = -5.503000 , Min = -5.585000 , Max = -5.321000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.523.156, 3 PS Sensor Value = 15.996000 , Min = 15.814000 , Max = 16.078000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.523.195, 4 PS Sensor Value = -16.505000 , Min = -16.587000 , Max = -16.323000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.523.221, 5 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:17:46.523.240, 6 PS Sensor Value = 4.002000 , Min = 3.820000 , Max = 4.084000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.480.644, 1 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.522.615, 2 PS Sensor Value = -5.501000 , Min = -5.583000 , Max = -5.319000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.522.729, 3 PS Sensor Value = 15.996000 , Min = 15.814000 , Max = 16.078000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.522.765, 4 PS Sensor Value = -16.505000 , Min = -16.587000 , Max = -16.323000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.522.788, 5 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000
PA43410-2,1,3,/vobs/atlas-idc/src/utils/logger/IDCLogger/IDC.cpp,48,19:18:46.522.810, 6 PS Sensor Value = 4.002000 , Min = 3.820000 , Max = 4.084000

I need to compare the PS Sensor Value, Min and Max value. (Min greater than PS Sensor greater than Max)

I'm expecting the output like below and here I should have only the normal lines.

What is normal lines? : If Min value greater than PS Sensor value && PS Sensor value is greater than Max value then the line is normal lines and that should removed.

Expected Output: PA43410-2 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000 PA43410-2 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000

Eg:

   If   Min < PS sensor value < Max,    // Don’t care the normal  lines.
         Throw this line away.
   Else  
        Pull this line to consolidated new file. //Only focus on abnormal lines.
  • 3
    1) That's a less than symbol. 2) What have you tried? Are you committed to particular technologies? You can edit your question. – Michael Homer Mar 31 '16 at 8:36
  • Why do you need sed? And why do you need the < symbol? – terdon Mar 31 '16 at 8:36
1

A simple solution is to use awk. Since awk splits its input into fields on whitespace (by default), the PS sensor value will be field 7 ($7), the min will be $11 and the max will be $15. You can, therefore, do:

awk  '$7>$11 && $7<$15' file > new.file

The default action when an expression evaluates to true in awk is to print the current line. Therefore, the command above will print all lines whose 7th field is between the min and max values.

  • Thanks for your quick reply. IPA43410-2 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000 PA43410-2 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000 PA43410-2 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000 PA43410-2 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000 PA43410-2 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000 – Albert Lévay Mar 31 '16 at 11:11
  • @AlbertLévay I have no idea what that is supposed to mean. Do you mean that the min and max values should be taken from the values given on each line? If so, you need to tell us. Please edit your question and clarify. Anyway, see updated answer. – terdon Mar 31 '16 at 11:13
  • Thanks for your quick reply. I'm expecting the output like below and here I should have only the normal lines. What is normal lines? : If Min value greater than PS Sensor value && PS Sensor value is greater than Max value then the line is normal lines and that should removed. PA43410-2 PS Sensor Value = 6.509000 , Min = 6.327000 , Max = 6.591000 PA43410-2 PS Sensor Value = 6.199000 , Min = 6.017000 , Max = 6.281000 – Albert Lévay Mar 31 '16 at 11:22
  • @AlbertLévay yes, and the min/max should be taken from each line, right? Your question didn't make that clear, I thought you wanted to set the min/max manually. Did you try the updated answer? – terdon Mar 31 '16 at 11:23
  • Hey Terdon. Yes I tried the updated one. this is what I want. Thank you so much. – Albert Lévay Mar 31 '16 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.