Skip to main content
added 289 characters in body
Source Link
Wildcard
  • 37.5k
  • 30
  • 149
  • 284

If you have lines only from the same day you can handle this like so:

sort -k6 -k3r logfile | uniq -f3 | sort -k3

If you have lines for more than one day you can still use this basic approach, but your sorting will have to get a lot fancier. The above command can only handle one day's records because it uses the time portion of the timestamp (e.g. 02:28:26) as a proxy for the entire timestamp.

If you have lines only from the same day you can handle this like so:

sort -k6 -k3r logfile | uniq -f3 | sort -k3

If you have lines only from the same day you can handle this like so:

sort -k6 -k3r logfile | uniq -f3 | sort -k3

If you have lines for more than one day you can still use this basic approach, but your sorting will have to get a lot fancier. The above command can only handle one day's records because it uses the time portion of the timestamp (e.g. 02:28:26) as a proxy for the entire timestamp.

Source Link
Wildcard
  • 37.5k
  • 30
  • 149
  • 284

If you have lines only from the same day you can handle this like so:

sort -k6 -k3r logfile | uniq -f3 | sort -k3