Skip to content

Instantly share code, notes, and snippets.

@notak
Last active January 9, 2020 22:20
Show Gist options
  • Save notak/d28200a0143264f49bac5e4479bb1a70 to your computer and use it in GitHub Desktop.
Save notak/d28200a0143264f49bac5e4479bb1a70 to your computer and use it in GitHub Desktop.
Sed to format an Apache Log Line
| egrep -v --line-buffered ".js|.css|.ico"
| sed -E
-e 's|([0-9.]+) - - [([0-9]+/[A-Za-z]+/[0-9]+):([0-9:]).?] "GET ([^ ]+) HTTP/([0-9.]+)" ([0-9]+) ([0-9]+) "([^"])" "[^ ] ([^"])"|\1\t\3\t\4\t\t\t\9|' -e "s/(Windows NT 10.0; Win64; x64)/Windows 10/"
-e "s/Linux; Android/Android/" \
-e "s|AppleWebKit/[0-9.] (KHTML, like Gecko) ||"
-e "s/iPhone; CPU iPhone OS ([0-9_.]+) like Mac OS X/iPhone \1/"
-e "s/Macintosh; Intel Mac OS/Mac OSX/"
-e "s|Chrome/([0-9.]) (Mobile )?Safari/[0-9.]|Chrome \1|"
-e "s|Chromium/[0-9.]+ Chrome|Chromium|"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment