remove GNU-specific `sort -V`, fix log concatenation order for {,e}searchlog
[logtools.git] / chckip
diff --git a/chckip b/chckip
index eca2128666fe0229260992a3757b1a3fb74157d3..1754c5179ec24966d041017b32853181ef8a1762 100755 (executable)
--- a/chckip
+++ b/chckip
@@ -12,4 +12,4 @@ err() {
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep -a "$@" | awk '{print $1}' | sort | uniq | xargs -L 1 host
+{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -n | cut -d' ' -f2-); } | grep -a "$@" | awk '{print $1}' | sort | uniq | xargs -L 1 host