#!/bin/bash source ~/.local/my/bash/bashrc WEBSITE_LOG_FILENAME="4in1.ws_access.log" FILES_LOG_FILENAME="files.4in1.ws_access.log" FULL_WEB=0 FULL_FILES=0 usage() { echo "usage: $0 [--full-web] [--full-files] [-h|--help]" } # Parse command-line arguments while [ "$#" -gt 0 ]; do case "$1" in --full-web) FULL_WEB=1 shift ;; --full-files) FULL_FILES=1 shift ;; -h|--help) usage exit 0 ;; *) 2>&1 echo "error: unknown option: $1" usage exit 1 ;; esac done # Execution branches if [ "$FULL_WEB" = "1" ]; then my_ssh root@4in1 cat "/var/log/nginx/$WEBSITE_LOG_FILENAME" | less elif [ "$FULL_FILES" = "1" ]; then my_ssh root@4in1 cat "/var/log/nginx/$FILES_LOG_FILENAME" | less else for f in $WEBSITE_LOG_FILENAME $FILES_LOG_FILENAME; do echo "> $f" my_ssh root@4in1 cat "/var/log/nginx/$f" | awk '{print $11}' | grep -v 4in1.ws | sed 's/"//g' | sort | uniq done fi