Hello,
At 11:35 PM 2/12/2003 +0100, you wrote:
Hi,
Would this work to sort the error logs...
cat error_log.* | sort -o sorted-error_log -k 2M -k 3n
(use -r if you want the order reversed)
I don't understand why, but when I do this, it sorts on the fourth field
as well (the time)...
It doesn't work with my sort or better with my LC_TIME settings. What's
your output of locale?
It says this:
[root@db2 root]# locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
As far as exactly what this means re: formatting, I have no idea ;-) I did
note a while ago that only(?) GNU sort gives the option to sort by month
names/abbreviations... at least, our Tru64 systems' native sort don't have
this option.
Cheers,
Guy.
If you want to sort with the '... -k xM ...' you need an appropriate
LC_TIME entry or it will not work. A possible one is:
LC_TIME="%a %b %w %H:%M:%S %Y"
But this must be handwaved according to locale(5) and then compiled with
localedef(3).
Lucky you if you have a charmap which matches the apache log files output ;).
Also read the info page on sort to see the difference between '-k 3n' and
'-k 3,3n'. This is food for comp.unix.shell, btw! They know for sure.
`-k POS1[,POS2]'
`--key=POS1[,POS2]'
Specify a sort field that consists of the part of the line between
POS1 and POS2 (or the end of the line, if POS2 is omitted),
_inclusive_. Fields and character positions are numbered starting
with 1. So to sort on the second field, you'd use `--key=2,2'
(`-k 2,2'). See below for more examples.
Best regards,
Roberto Nibali, ratz
--
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc
_______________________________________________
LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
or go to http://www.in-addr.de/mailman/listinfo/lvs-users
|