Linux 删除指定目录中所有大小为零的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9907559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:27:37  来源:igfitidea点击:

remove all the files of zero size in specified directory

linuxunixubuntu

提问by Hema Latha

Thanks,in advance I want to remove all the zero size files in specified directory,can u tell me the command how to do it on Ubuntu OS.

谢谢,事先我想删除指定目录中的所有零大小文件,你能告诉我如何在 Ubuntu 操作系统上执行此操作的命令。

Thanks' Mukthyar

谢谢穆克蒂亚尔

采纳答案by soulmerge

find . -size 0c -deleteremoves all such files in the current folder.

find . -size 0c -delete删除当前文件夹中的所有此类文件。

回答by fragmentedreality

cd DIRECTORY
find . -size 0

If you want to run a command on the files found (e.g. delete)

如果要对找到的文件运行命令(例如删除)

find . -size 0 -exec rm {} \;