带有 -C 和 -W 选项的 tcpdump 文件名
tcpdump filename with -C and -W option
我正在尝试在 Linux 中捕获 tcpdump,我使用了 -C
和 -W
选项来启用捕获文件大小限制为 250MB 的 tcpdump。
sudo tcpdump -i any -s0 -vvv -W 999 -C 250 -w FILENAME.pcap. -Z root
另一方面,我得到的输出是
FILENAME.pcap.001
FILENAME.pcap.002
FILENAME.pcap.003
但是我想知道如何把输出的文件名改成:
FILENAME001.pcap
FILENAME002.pcap
FILENAME003.pcap
感谢您提出的任何帮助建议!
Tcpdump 没有内置这样的功能。你可以 运行 最后像这样重命名你的文件:
for f in FILENAME.pcap.*; do
mv "$f" "$(echo $f | sed 's/FILENAME.pcap.\(.*\)/FILENAME.pcap/')";
done
您可以使用 -z 功能代表:
-z 后旋转命令
与 -C 或 -G 选项一起使用,这将使 tcpdump 运行 “postrotate-command file” 其中文件是正在保存的文件
每次旋转后关闭。例如,指定 -z gzip 或 -z bzip2 将使用 gzip 或 bzip2 压缩每个保存文件。
Note that tcpdump will run the command in parallel to the capture, using the lowest priority so that this doesn't disturb the capture
process.
And in case you would like to use a command that itself takes flags or different arguments, you can always write a shell script that will
take the savefile name as the only argument, make the flags & arguments arrangements and execute the command that you want.
我正在尝试在 Linux 中捕获 tcpdump,我使用了 -C
和 -W
选项来启用捕获文件大小限制为 250MB 的 tcpdump。
sudo tcpdump -i any -s0 -vvv -W 999 -C 250 -w FILENAME.pcap. -Z root
另一方面,我得到的输出是
FILENAME.pcap.001
FILENAME.pcap.002
FILENAME.pcap.003
但是我想知道如何把输出的文件名改成:
FILENAME001.pcap
FILENAME002.pcap
FILENAME003.pcap
感谢您提出的任何帮助建议!
Tcpdump 没有内置这样的功能。你可以 运行 最后像这样重命名你的文件:
for f in FILENAME.pcap.*; do
mv "$f" "$(echo $f | sed 's/FILENAME.pcap.\(.*\)/FILENAME.pcap/')";
done
您可以使用 -z 功能代表:
-z 后旋转命令 与 -C 或 -G 选项一起使用,这将使 tcpdump 运行 “postrotate-command file” 其中文件是正在保存的文件 每次旋转后关闭。例如,指定 -z gzip 或 -z bzip2 将使用 gzip 或 bzip2 压缩每个保存文件。
Note that tcpdump will run the command in parallel to the capture, using the lowest priority so that this doesn't disturb the capture
process.
And in case you would like to use a command that itself takes flags or different arguments, you can always write a shell script that will
take the savefile name as the only argument, make the flags & arguments arrangements and execute the command that you want.