Count per line in txt file

In a txt file called, eso.txt, I have:

......
  3  where process_status_flag = 70 and LISTENER_ID in (930.00, 931.00, 932.00, 933.00, 934.00)
  4  group by LISTENER_ID
  5  order by LISTENER_ID;

  LISTENER      COUNT                                                           
---------- ----------                                                           
       930       5145                                                           
       931       5344                                                           
       932       5387                                                           
       933       5517                                                           
       934       4942                                                           

SQL> 
SQL> spool off

I need to grep the below if any of LISTENER has more than 5,500 on COUNT and e-mail out to me.

  LISTENER      COUNT                                                           
---------- ----------                                                           
       930       5145                                                           
       931       5344                                                           
       932       5387                                                           
       933       5517                                                           
       934       4942                                                           

So, in this case, LISTENER 933 has more than 5,500 COUNT, I need to e-mail it out the entire of this.

  LISTENER      COUNT                                                           
---------- ----------                                                           
       930       5145                                                           
       931       5344                                                           
       932       5387                                                           
       933       5517                                                           
       934       4942                                                           

Please advise. :confused:

Try:

awk 's{s=s RS $0} $2+0>5000{p=1} /^ *LISTENER /{s=$0} !NF && s && p{print s;exit}END{if(!p)exit 1}' infile

or

awk '/^ *LISTENER /{for(i=6; i<=NF; i+=2) if($i>5000)p=1;if(p)print;exit}END{if(!p)exit 1}' RS= infile
1 Like

Thank you so much! It works great!

Try this..

 
awk '/LISTENER /,/SQL/{a=a"\n"$0;b=$2;i++}END{gsub("SQL>","",a);for(i in b){if(b>5500 && b!~/[C\-]/){print b;print a;exit}}}'
  LISTENER      COUNT                                                            
---------- ----------                                                            
       930       5145                                                            
       931       5344                                                            
       932       5387                                                            
       933       5517                                                            
       934       4942        
1 Like