Ubuntu – How to recursively delete files filled with zeros


I have many files in a folder tree, of which some are filled with zeros and others are real files.

How can I delete files filled with zeros recursively?

Best Answer

  • You should be able to identify sparse files by using the find command:

    find -type f -printf "%S\t%p\n" 2>/dev/null | awk '{if ($1 < 1.0) print $1 $2}'

    You can probably add some more find parameters to look for semi-sparse files, though those will probably depend more on your specific situation.

    source: http://www.commandlinefu.com/commands/view/8757/find-sparse-files

  • Related Question