linux截取文件区间内容

January 11, 2022 默认分类

startLine=`grep -n "2022-01-09 03:32" all-log.log |head -1|awk -F':' '{print $1}'`
endLien=`grep -n "2022-01-09 04:04" all-log.log |tail -n 1|awk -F':' '{print $1}'`
cat all-log.log| head -n ${endLine} | tail -n +${startLine} > 2022-01-09_0332-0404.log

添加新评论