0

I have a file TBS.log like this

SYSAUX      70.12
SYSTEM      81.74
UNDOTBS1    5.66
UNDOTBS2    1.93
UNDOTBS3    1.79
USERS       .16

I need to get the output as following. If 2nd column is greater than 70, then it should print Success Message, else it should print Failure Message For example

SUCCESS: SYSAUX > 70%
FAILURE: UNDOTBS1 < 70%

It should read every line and give success or failure message

  • Hello Moses. What have you tried so far? Generally, people here are happy to help, but we're not a script-writing service. – roaima Feb 25 at 22:41
  • Hi roaima, tried this for i in $(cat TBS.log|awk '{print $2}') do print if cat TBS.log |grep -i ${i}|awk '{print $2}' > 70 then cat TBS.log |grep -i ${i} echo "SUCCESS" else cat TBS.log |grep -i ${i} echo "FAILURE" print fi; done – Moses Feb 25 at 23:16
  • Moses, please put that into your post where everyone can easily see it. (Ideally make it seem like you had put that in originally. There's no need to write "edit" or "update" because there's a full edit history anyway.) – roaima Feb 26 at 0:10
0
awk '{
    if ($2+0 > 70) 
      print "SUCCESS:", $1, "> 70%"; 
    else 
      print "FAILURE:", $1, "<= 70%";
}' TBS.log 
SUCCESS: SYSAUX > 70%
SUCCESS: SYSTEM > 70%
FAILURE: UNDOTBS1 <= 70%
FAILURE: UNDOTBS2 <= 70%
FAILURE: UNDOTBS3 <= 70%
FAILURE: USERS <= 70%
  • Thank you Steeldriver – Moses Feb 26 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our , and 我在天马彩票平台输了三十万

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