I am trying to calculate what is the % of successful queries in apache log. I have two commands:
cat access_log|cut -d' ' -f10|grep "2.."|wc -l
cat access_log|cut -d' ' -f10|wc -l
They return me the number of successful queries and total queries number. I want to calculate what is the % of successful requests using bash and if it is possible - it should be 1 line script. It suppose to output just the % number like - 50 or 12 without any additional info.
I tried to use bc with it but failed because of lack of knowledges. Can somebody help me?