linux - 如何在linux中删除许多0字节的文件?

标签 linux file find xargs delete-file

我有一个目录,其中包含许多 0 字节文件。当我使用 ls 命令时,我什至看不到文件。我正在使用一个小脚本来删除这些文件,但有时甚至不会删除这些文件。这是脚本:

i=100
while [ $i -le 999 ];do
    rm -f file${i}*;
    let i++;
done

有没有其他方法可以更快地做到这一点?

最佳答案

使用 find 结合 xargs

find . -name 'file*' -size 0 -print0 | xargs -0 rm

您避免为每个文件启动 rm

关于linux - 如何在linux中删除许多0字节的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3157343/

相关文章:

linux - 使用 Ansible 自动设置加密分区

c - 使用 popen() 将密码传递到 Veracrypt - 安全吗?

c - C 程序中的 wpa_supplicant 用法

java - spring boot 文件上传进度

python查找JSON中所有出现的键并修改值

python - Linux 错误 : sh: qsub: command not found

android - setReadOnly 不工作

java - 在不同时间将多行写入文件

查找名称为数字文本的文件

jquery - 在 href (jQuery) 中查找带有图像扩展名的 <a>