remove GNU-specific `sort -V`, fix log concatenation order for {,e}searchlog
[logtools.git] / esearchlog
index 228c0daec3a476c3904cb5497dcb6fcfe494960a..a9cc280967c93382611b623b734dfe01d07f9339 100755 (executable)
@@ -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"/error.log /var/log/"$SERVER"/error.log.1; gzip -cd $(ls /var/log/"$SERVER"/error.log.*.gz | sort -V); } | grep --color=auto -a "$@"
+{ gzip -cd $(ls /var/log/"$SERVER"/error.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -rn | cut -d' ' -f2-); cat /var/log/"$SERVER"/error.log.1 /var/log/"$SERVER"/error.log; } | grep --color=auto -a "$@"