Hello friends,
I have written a script and i need to add some part into it so that i could print out more results depending on more conditions,
This is the core part of the script which does the actual work:
echo "$j" && nawk -v stat=$2 'NR==FNR && $1==stat{STATE=$2}/State=\[stat\]Action.*in/gsub(/^\[|\]/,"",$(NF-1)){sum+=$(NF-1);avg=(sum/NR)} END { print "Avg Proc Time for " STATE " =",avg}' state.cfg $j;
$j
is an input which is coming from output of a previously run find command:
/data/log/rfe/profile3.log
/data/log/rfe/profile4.log
/data/log/rfe/profile3.log.2014-05-20-00
/data/log/rfe/profile4.log.2014-05-20-00
/data/log/rfe/profile3.log.2014-05-20-01
/data/log/rfe/profile4.log.2014-05-20-01
/data/log/rfe/profile3.log.2014-05-20-02
I need to mark result in output which are higher than, lets say "250" with a star sign. So, desired output is:
-bash-3.00$ cat avg_proc_time_results.txt
/data/log/rfe/profile3.log.2014-05-20-00
Avg Proc Time for Charging = 199.98
/data/log/rfe/profile4.log.2014-05-20-00
Avg Proc Time for Charging = 200.021
/data/log/rfe/profile3.log.2014-05-20-01
Avg Proc Time for Charging = 214.448
/data/log/rfe/profile4.log.2014-05-20-01
Avg Proc Time for Charging = 213.565
/data/log/rfe/profile3.log.2014-05-20-02
Avg Proc Time for Charging = 170.646
/data/log/rfe/profile4.log.2014-05-20-02
Avg Proc Time for Charging = 168.457
/data/log/rfe/profile3.log.2014-05-20-03
Avg Proc Time for Charging = 265.9*
/data/log/rfe/profile4.log.2014-05-20-03
Avg Proc Time for Charging = 258.402*
Note: Current output file is just the one without star marks.
I have tried this
echo "$j" && nawk -v stat=$2 'NR==FNR && $1==stat{STATE=$2}/State=\[stat\]Action.*in/gsub(/^\[|\]/,"",$(NF-1)){sum+=$(NF-1);avg=(sum/NR)} END {if(avg > 250) print "Avg Proc Time for " STATE " ="avg"*"}' state.cfg $j;
but it is only giving the following output; not all results..
/data/log/rfe/profile3.log.2014-05-20-00
/data/log/rfe/profile4.log.2014-05-20-00
/data/log/rfe/profile3.log.2014-05-20-01
/data/log/rfe/profile4.log.2014-05-20-01
/data/log/rfe/profile3.log.2014-05-20-02
/data/log/rfe/profile4.log.2014-05-20-02
/data/log/rfe/profile3.log.2014-05-20-03
/data/log/rfe/profile4.log.2014-05-20-03
/data/log/rfe/profile3.log.2014-05-20-04
Avg Proc Time for Charging =265.9*
/data/log/rfe/profile4.log.2014-05-20-04
Avg Proc Time for Charging =258.402*
/data/log/rfe/profile3.log.2014-05-20-05
I have tried more thigns but could not achieve it,
i would appreciate any help,
thanks in advance,
KR
Eagle