1. 得到具体的时间段 

133.228.58.10 12/Mar/2021:17:37:46 +0800] 1011022 1253594651655540736] "POST /api/teapi/queue/impexp/expStatus HTTP/1.1" 0.072 406 200 "http://8.131.102.36:7000/" "Mozill

d2=`date +%d/%h/%Y:%H:%M -d "100 minutes ago"`
d1=`date +%d/%h/%Y:%H:%M -d "300 minutes ago"`

2.得到目标的时间段的日志

sed 's#\[##g' /tmp/a.txt  |awk -v b1=$d1 -v b2=$d2 '{if (b1<$2 && $2<b2) print }'

 -v b1=$d1 定义变量

参考:https://blog.csdn.net/ddu32445/article/details/102377497

3.cat /tmp/a.txt |sed 's#\[##g'|sed 's#\]##g'|awk  -v b=$d '{if($1 > b) print}'

cat /tmp/a.txt |sed 's#\[##g'|sed 's#\]##g'|awk  -v b=$d '$1 > b{ print}'

效果一样

相关文章:

  • 2022-01-28
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
猜你喜欢
  • 2022-12-23
  • 2021-06-21
  • 2021-10-02
  • 2021-05-30
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案