删除大量文件

时间:2014-01-30 15:21:28

标签: linux bash

我正在编写一个脚本来删除linux中的大量文件。该脚本将在crontab中每两分钟运行一次。我试过用了  find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" -print0 | xargs -0 ls -lt | tail -$del | awk '{print $8}'

并将其保存到变量并尝试使用rm命令删除,但dint运行。我发现find . -type f -delete可用于删除文件,但我不知道如何将此部分添加到我的命令中。我该怎么做?

1 个答案:

答案 0 :(得分:2)

只需将-print0替换为-delete

find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" -delete