In an unpolished version, a Bash-script could look like this, assuming that your data is contained in `datafile`: #!/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 ( count == 0 ? "NaN" : total/count); }' printf "Number of logins (successful and failed) via Mobile:\n" grep -c 'Source=Mobile' datafile A brief elucidation: - Q2) Calculation of the Average time: the `grep` command extracts the time values (which are assumed to be all in seconds). These values are piped into the `awk` command, which calculates their average, and then prints that average.