截取 2019-06-25 10:10 到 2019-06-25 10:20 之间的日志记录,apollo-service.log 为你要截取的文件名称, new2.log 截取之后保存日志的文件名称。
sed -n ‘/2019-06-25 10:10/, /2019-06-25 10:20/p‘ apollo-service.log > new2.log
sed -n ‘/2019-06-25 10:20:47/, /2019-06-25 10:26:47/p‘ apollo-service.log > new2.log
sed -n ‘/2019-06-25 10:20:47.728/, /2019-06-25 10:26:47.728/p‘ apollo-service.log > new2.log
说明:时间段可根据自己的需要进行修改,可精确到毫秒。
截取 apollo-service.log 文件中的100 - 500 行的日志, new.log 为截取保存之后的文件。
sed -n ‘100,500‘p apollo-service.log > new.log
原文:https://www.cnblogs.com/ming-blogs/p/11081439.html