Skip to content

Instantly share code, notes, and snippets.

@qzchenwl
Last active August 29, 2015 14:23
Show Gist options
  • Save qzchenwl/86764c6e91e3e78d0a3c to your computer and use it in GitHub Desktop.
Save qzchenwl/86764c6e91e3e78d0a3c to your computer and use it in GitHub Desktop.
Filter HTTP request log by IP. Redirect log to file named with IP.
awk 'BEGIN{RS="\\+\\+\\+\\+\\+\\+\\+\\+\\+ Incoming Request \\+\\+\\+\\+\\+\\+\\+\\+\\+"; FS="\n"} { match($0, /X-Real-IP: ([0-9\.]+)/, ary); fn=ary[1]".txt"; print $0 >> fn }' debug.log
grep -l 'HTTP/1.1 412 Precondition Failed' *.txt | while read file; do mv $file 412; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment