Skip to content

Instantly share code, notes, and snippets.

@leegin
Created October 19, 2019 23:23
Show Gist options
  • Save leegin/cfe92cc7fead87663be9187f0a5fdf57 to your computer and use it in GitHub Desktop.
Save leegin/cfe92cc7fead87663be9187f0a5fdf57 to your computer and use it in GitHub Desktop.
#/bin/bash
#Script to parse the logs and then convert it to json
read -p ('Enter the name of the log file which you want to parse:') file
jq -Rs '[ split("\n")[] | select(length > 0) | split(",") | {type: .[0], date: .[1], source_ip: .[2], response_time: .[3], target_url: .[4], http_code: .[5]}]' $file > output.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment