Find all zero-byte files in directory and subdirectories

后端 未结 4 619
南笙
南笙 2021-01-30 03:05

How can I find all zero-byte files in a directory and its subdirectories?

I have done this:

#!/bin/bash
lns=`vdir -R *.* $dir| awk \'{print $8\"\\t\"$5}\         


        
4条回答
  •  时光取名叫无心
    2021-01-30 03:20

    Bash 4+ tested - This is the correct way to search for size 0:

    find /path/to/dir -size 0 -type f -name "*.xml"
    

    Search for multiple file extensions of size 0:

    find /path/to/dir -size 0 -type f \( -iname \*.css -o -iname \*.js \)
    

    Note: If you removed the \( ... \) the results would be all of the files that meet this requirement hence ignoring the size 0.

提交回复
热议问题