常用的linux命令分享,常用linux命令分享


查询log中某个时间段内的日志

sed -n '/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p' test.log

日期必须是log中打印出来的,使用grep '2014-12-17 16:17:20' test.log 查询是否存在时间

tail -n 10 test.log 查询日志尾部最后10行的日志;

tail -n +10 test.log 查询10行之后的所有日志;

head -n 10 test.log 查询日志文件中的头10行日志;

head -n -10 test.log 查询日志文件除了最后10行的其他所有日志;

相关内容