Log parser

    Paste log lines. ISO-8601 timestamps and 10-digit Unix seconds are highlighted and listed in order of appearance.

    Matches (0)
    • No timestamps detected yet.

    Related Guides & Tutorials

    // developers also read

    Terminal Equivalent

    Rip epoch digits and structured dates out of logs using grep, awk, and GNU date.

    bash
    # Extract all timestamps from a log file
    grep -oP '\d{10}' /var/log/app.log
    
    # Convert all timestamps in a log to readable dates
    grep -oP '\d{10}' /var/log/app.log | \
      while read ts; do
        echo "$ts -> $(date -d @$ts)"
      done
    
    # Find log entries in a time range
    awk -F'[][]' '{print $2}' access.log | \
      awk -F/ '{print $3"-"$2"-"$1}' | sort | uniq -c
    
    # Parse nginx access log timestamps
    awk '{print $4}' /var/log/nginx/access.log | \
      cut -c2- | sort | uniq -c
    
    # Filter logs by date range using Unix timestamps
    start=$(date -d "2024-12-01" +%s)
    end=$(date -d "2024-12-07" +%s)
    awk -v s=$start -v e=$end '$1>=s && $1<=e' timestamps.log

    How It Works

    Log files use many timestamp formats: Unix seconds, ISO 8601, Apache Common Log Format ([07/Dec/2024:04:00:00 +0000]), syslog format (Dec 7 04:00:00), and RFC 3339. Parsing requires identifying the format and converting to a common representation for comparison. The key challenge is timezone — logs from distributed systems may use different zones, making naive string comparison incorrect. Always normalize to UTC first.