This is the format of timestamp on which 2019-06-29T12:39:23.428Z
I want to sort. But the year is delimited by -
and the time is delimited by :
and both year and time are separated my T'
.
sort -t '-' -k1 -k2 -k3 -t ':' -k1 -k2 -k3 myLog2.txt
Tried this.
Advertisement
Answer
You can manually pick out each field to sort with -k
from man:
-k, --key=KEYDEF sort via a key; KEYDEF gives location and type
So something like this should sort your output:
sort -k 1,4 -k 6,7 -k 9,10 -k 12,13 -k 15,16 -k 18,19 -k 21,23 <file>
However: a simple sort should solve your issue.
sort <file>