• Home
  • -
  • Useful Commands

Useful Commands

Create Database (MySQL) in 2019 - with emoji support

    CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Access Log Parsing


    # per URL
    cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' | sed 's/\?.*//g' | sort | uniq -c | sort -rn

    # per Status Code
    cat access.log | cut -d '"' -f3 | cut -d ' ' -f2 | sort | uniq -c | sort -rn

    # find URLs with status code (404)
    awk '($9 ~ /404/)' access.log | awk '{print $7}' | sort | uniq -c | sort -rn