截取日志

2015-09-01 0 617
截取日志
#!/bin/sh

logFileName="pcrf_stack.log"
startTime="2014-10-11T22:30:00"
endTime="2014-10-11T23:30:00"
outPutFileName="./stack_log_2230_2330.log"

startLineNum=`grep -n "$startTime" $logFileName | head -n1 | awk -F: '{print $1}'`
endLineNum=`grep -n "$endTime" $logFileName | head -n1 | awk -F: '{print $1}'`

echo $startLineNum
echo $endLineNum

sed -n "${startLineNum}, ${endLineNum}w $outPutFileName" $logFileName

遇见资源网 shell 截取日志 http://www.ox520.com/17122.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务