- #!/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
- #该片段来自于http://www.codesnippet.cn/detail/2010201410705.html
来源: http://www.codesnippet.cn/detail/2010201410705.html