如何通过时间捕捉与sngrep -O一个旋转的文件?

问题描述 投票:0回答:1

我用tcpdump捕捉到每小时1个文件,并保存文件名以%H有每小时1个文件的文件旋转。现在我试图使用sngrep -O file%H.pcap,但总是从字面上可以节省相同file%H.pcap文件。

如何为它们命名file01.pcap, file02... file24.pcap?

我想与"timeout 1h sngrep... "使用仅捕获1小时。

非常感谢!

shell tcpdump strftime
1个回答
0
投票

使用date命令。

sngrep -O "file$(date +%H).pcap"

例:

  $ printf "%s\n" "file$(date +%H).pcap"
  file20.pcap

  $ date
  Sat Feb  9 20:16:29 IST 2019
© www.soinside.com 2019 - 2024. All rights reserved.