#!/bin/bash# This script is used parse apache access log filtering specific ip and http outcome#httpStatusDelimiter=" ";stringOld=' ';ipsSeparator="\|"read -p "Which log file do you want to parse? " file2parse
if[ -z "$file2parse"]thenecho"Nothing to do.";elseif[ ! -f "$file2parse"];thenecho"File not found!";elseecho"Parsing file: $file2parse";read -p "Which HTTP status search? " httpStatus;while ! [["$httpStatus" -gt 1]];doread -p "Sorry integers only, please retype HTTP status:" httpStatus
doneecho"Please insert ip list (only one ip in a single line)";whileread -r line &&[[ -n "$line"]];doips="$ips""$ipsSeparator""$line";doneif[[ -n $ips]];thenips=${ips:2};fihttpStatus="${httpStatusDelimiter}$httpStatus${httpStatusDelimiter}"; grep "$ips""$file2parse"|grep -F "$httpStatus";fifi
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.