#!/usr/bin/env sh # Function to display usage usage() { echo "Usage: $0 --input " exit 1 } # Check if at least 2 arguments are provided if [ "$#" -lt 2 ]; then usage fi # Parse arguments while [[ "$#" -gt 0 ]]; do case $1 in --input) input="$2" shift 2 ;; *) usage ;; esac done # Check if input is set if [ -z "$input" ]; then usage fi # Read from input file, parse with regex, and write to the csv file regex="(?.{26}) (?\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) (?[^ ]+) (?GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|NA|PROPFIND) (?[^ ]+) (?[^ ]+) (?[^ ]+) (?[^ ]+) (?[^ ]+) (?\d+) (?\d+) (?\d+) (?[^\n]+).*" parse2csv --regex "$regex" --input "$input"