In an unpolished version, a Bash-script could look like this: #!/bin/bash printf "IPs where status is fail:\n" grep -z -oP 'IP=\K.*\n(?=STATUS=FAIL)' datafile printf "Avg time taken by all requests where status is 'success':\n" grep -z -oP 'STATUS=SUCCESS\nTIME=\K\d+' datafile | \ awk '{ total += $1; count++ } END { print total/count }' printf "Number of logins (successful and failed) via Mobile:\n" grep -c 'Source=Mobile' datafile