date | title | tags | |
---|---|---|---|
2020-11-23 12:51:00 +0000 |
script |
|
and also https://gist.github.com/f6o
- Practical Common Lisp
- cl-cookbook
- HyperSpec
主に nginx 用デフォルトのログで先頭にIPアドレスがあればいい
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -n | tail -n 5
#!/bin/bash
set -e
AWKSCRIPT='{print}'
case "$1" in
"path" ) AWKSCRIPT='{print $7}' ;;
"ip" ) AWKSCRIPT='{print $1}' ;;
esac
PRINT_LINES="5"
if [ -n "$2" ];
then
PRINT_LINES="$2"
fi
pushd /var/log/nginx > /dev/null
cat access.log.1 access.log | awk "$AWKSCRIPT" | sort | uniq -c | sort -n | tail -n "$PRINT_LINES"
popd > /dev/null