Skip to content

Instantly share code, notes, and snippets.

@vkobel
Created September 14, 2016 08:33
Show Gist options
  • Save vkobel/dc759c5d39a8afa16d560fc6af7751b7 to your computer and use it in GitHub Desktop.
Save vkobel/dc759c5d39a8afa16d560fc6af7751b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# filter on 2 colums (id=... and datetime) then sort and uniq by the first col only (id) the sort by datetime
cat /var/log/nginx/access.log | sed -n 's/.*\[\(.\+\)\].*id=\(.\{6\}\).*/\2 -> \1/p' | sort -u -k1,1 | sort -k3
# output would look like:
# d77ea4 -> 13/Sep/2016:07:17:36 +0200
# 11ff21 -> 13/Sep/2016:07:45:10 +0200
# 628bf5 -> 13/Sep/2016:07:52:09 +0200
# 9d8a4c -> 13/Sep/2016:07:56:53 +0200
# 64c435 -> 13/Sep/2016:08:27:50 +0200
# 8155ae -> 13/Sep/2016:08:51:10 +0200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment