Skip to content

Instantly share code, notes, and snippets.

@leegin
Last active October 15, 2019 14:15
Show Gist options
  • Save leegin/c8337075e5d2ccda1ebdcbdff32f1d2d to your computer and use it in GitHub Desktop.
Save leegin/c8337075e5d2ccda1ebdcbdff32f1d2d to your computer and use it in GitHub Desktop.
#/bin/bash
#Script to parse the log to get IP address and URL and then convert it to json
read -p "Enter the name of the log file which you want to parse: " file
less $file | awk '{print $1","$15}' | grep http | cut -d ")" -f1 | sed 's/+//' > data.txt
jq -Rs '[ split("\n")[] | select(length > 0) | split(",") | {IP_address: .[0], URL: .[1]} ]' data.txt > data.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment