Thursday, May 8, 2025

access logs to PDT

zgrep "text" /var/log/nginx/access.log | awk '{print $6}' | sed -e 's/\"/\ /g' | awk -F'[:/]' '{
  # Build a new date string that GNU date can understand
  timestamp = $1 " " $2 " " $3 " " $4 ":" $5 ":" $6
  cmd = "TZ=\"America/Los_Angeles\" date -d \"" timestamp " UTC\" \"+%Y-%m-%d %H:%M:%S %Z\""
  cmd | getline converted
  close(cmd)
  print converted
}'