Skip to content

Instantly share code, notes, and snippets.

@artygus
Created October 27, 2017 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artygus/c8d39f3bab621bee7de8ed0cb5865ed1 to your computer and use it in GitHub Desktop.
Save artygus/c8d39f3bab621bee7de8ed0cb5865ed1 to your computer and use it in GitHub Desktop.
Extract date from gzipped access log
gzip -dc access.log.1.gz | head -c 200 | head -n 1 | awk '{print $4}' | xargs -I {} date -jf "[%d/%b/%Y" \{} +%Y-%m-%d
@artygus
Copy link
Author

artygus commented Jul 16, 2018

on linux it's gonna be

gzip -dc access.log.1.gz | head -c 200 | head -n 1 | awk '{print $4}' | grep -Eo '[0-9]{2}/\w+/[0-9]{4}' | sed 's/\//-/g' | xargs -I {} date -d \{} +%Y-%m-%d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment