I have many log files, like that
log file 1
2016-09-11_19:40:15.537#15437 [INFO] A1
2016-09-11_19:40:15.537#15437 [WARN] A2
2016-09-11_19:40:15.542#15437 [INFO] A3
log file 2
2016-09-11_19:40:15.537#437 [INFO] B1
2016-09-11_19:40:15.540#437 [INFO] B2
I wish I can merge them by script or other method like that sort by time
2016-09-11_19:40:15.537#15437 [INFO] A1
2016-09-11_19:40:15.537#15437 [WARN] A2
2016-09-11_19:40:15.537#437 [INFO] B1
2016-09-11_19:40:15.540#437 [INFO] B2
2016-09-11_19:40:15.542#15437 [INFO] A3
How do I to merge the files with efficient way ? thanks !
Ref: Merging multiple log files by date including multilines
As mentioned in the above question, if you are certain that all the log lines start with timestamp, you can do:
cat logA.log logB.log | sort -n
This would not work when there are other lines such as stack trace which do not start with timestamp.
I think you can check out the above question and answers if your considering a similar scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With