I have a process that generates output mostly in lexicographically sorted order according to a (timestamp) field, but occasionally the lines will be output in the wrong order:
2014-08-14 15:42:02.019220203 ok
2014-08-14 15:42:03.523164367 ok
2014-08-14 15:42:04.525655832 ok
2014-08-14 15:42:06.523324269 ok
2014-08-14 15:42:05.930966407 oops
2014-08-14 15:42:07.643347946 ok
2014-08-14 15:42:07.567283110 oops
How can I identify each location where the data are "unsorted"?
Expected output (or similar):
2014-08-14 15:42:05.930966407 oops
2014-08-14 15:42:07.567283110 oops
I need a solution that works as the data are generated (e.g. in a pipeline); it's less useful if it only operates on complete files. sort --check
would be ideal but it only outputs the first point of disorder; I need a full listing.