需要在bash的日志文件中减去即时行时间差吗?

需要在bash的日志文件中减去即时行时间差吗?,bash,shell,Bash,Shell,我有一个日志文件,它是从备份还原过程中生成的。我想知道与以前相比是否有任何缓慢。因此,我需要将每个恢复模块的时间差异设置为一个单独的恢复模块时间。这是我的日志文件 2019-10-26 08:06:56 6503 6501 Begin restore logical log 2290281 (Storage Manager copy ID: 1 1571839465). 2019-10-26 08:14:05 6503 6501 Completed restore logical log

我有一个日志文件,它是从备份还原过程中生成的。我想知道与以前相比是否有任何缓慢。因此,我需要将每个恢复模块的时间差异设置为一个单独的恢复模块时间。这是我的日志文件

 2019-10-26 08:06:56 6503  6501 Begin restore logical log 2290281 (Storage Manager copy ID: 1 1571839465).
 2019-10-26 08:14:05 6503  6501 Completed restore logical log 2290281.
 2019-10-26 08:14:09 6503  6501 Begin restore logical log 2290282 (Storage Manager copy ID: 1 1571839691).
 2019-10-26 08:21:09 6503  6501 Completed restore logical log 2290282.
 2019-10-26 08:21:13 6503  6501 Begin restore logical log 2290283 (Storage Manager copy ID: 1 1571839892).
所以,我的期望只是显示在结果下面

deference between (2019-10-26 08:14:05) and  (2019-10-26 08:06:56) 
deference between (2019-10-26 08:21:09) and  (2019-10-26 08:14:09) 
所以我的预期输出是

7 minutes and 11 seconds
7 minutes and 00 seconds 

可以使用bash/date进行简单的日期计算

PREV=
DELTA=0
while read dt  tm data ; do
  CURR=$(date '+%s' -d "$dt $tm");
  [ "$PREV" ] && DELTA=$((CURR-PREV));
  PREV=$CURR ;
  echo "$DELTA sec $dt $tm $data" ;
done < logfile

因此,我们鼓励人们增加他们为解决自己的问题所付出的努力,因此请添加同样的努力,然后让我们知道。
echo "$((DELTA/60)) min and $((DELTA%60)) sec $dt $tm $data" ;

Output:
0 min and 0 sec 2019-10-26 08:06:56 6503  6501 Begin restore logical log 2290281 (Storage Manager copy ID: 1 1571839465).
7 min and 9 sec 2019-10-26 08:14:05 6503  6501 Completed restore logical log 2290281.
0 min and 4 sec 2019-10-26 08:14:09 6503  6501 Begin restore logical log 2290282 (Storage Manager copy ID: 1 1571839691).
7 min and 0 sec 2019-10-26 08:21:09 6503  6501 Completed restore logical log 2290282.