如何在Linux中删除多个0字节的文件? [英] How to delete many 0 byte files in linux?

查看:373
本文介绍了如何在Linux中删除多个0字节的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有很多0字节文件的目录。当我使用ls命令时甚至无法看到这些文件。我正在使用一个小脚本删除这些文件,但有时甚至不删除这些文件。这是脚本:

  i = 100 
while [$ i -le 999]; do
rm -f文件$ {i} *;
让我++;
完成

是否有其他方法可以更快地执行此操作?

解决方案使用 find xargs

  find。 -name'文件*'-size 0 -print0 | xargs -0 rm 

您避免开始 rm 为每个文件。


I've a directory with many number of 0 byte files in it. I can't even see the files when I use the ls command. I'm using a small script to delete these files but sometimes that does not even delete these files. Here is the script:

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

Is there any other way to do this more quickly?

解决方案

Use find combined with xargs.

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

You avoid to start rm for every file.

这篇关于如何在Linux中删除多个0字节的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆