http://www.unix.com/unix-dummies-questions-answers/25514-how-find-files-not-empty.html
You can use the find command to find non-zero length files:
find path -type f ! -size 0
In most UNIX implementations, the -size expression can also be used to search for file sizes of exactly N bytes (-size Nc), greater-than N bytes (-size +Nc), and less-than N bytes (-size -Nc).
The confusing thing is that the numeric following -size is, by default, 512-byte blocks not a byte count. The numeric must be followed by a 'c' for that. The following command will find files less than 2KB:
find . -type f -size -2048c -print
Conversely, for files greater than 2KB:
find . -type f -size +2048c -print
One note, the 512-byte block count does not directly translate into bytes. It's a long story. You can display a file's block usage with, under Solaris, ls -s. Stick to byte counts.
Oh, yes, one more thing, you can search for a specific range by using multiple -size expressions as long as they can all be satisfied by a single file. For example, locate files larger than 2KB and less than 8KB (inclusive):
find . -type f -size +2047c -size -8193c
You can use the find command to find non-zero length files:
find path -type f ! -size 0
In most UNIX implementations, the -size expression can also be used to search for file sizes of exactly N bytes (-size Nc), greater-than N bytes (-size +Nc), and less-than N bytes (-size -Nc).
The confusing thing is that the numeric following -size is, by default, 512-byte blocks not a byte count. The numeric must be followed by a 'c' for that. The following command will find files less than 2KB:
find . -type f -size -2048c -print
Conversely, for files greater than 2KB:
find . -type f -size +2048c -print
One note, the 512-byte block count does not directly translate into bytes. It's a long story. You can display a file's block usage with, under Solaris, ls -s. Stick to byte counts.
Oh, yes, one more thing, you can search for a specific range by using multiple -size expressions as long as they can all be satisfied by a single file. For example, locate files larger than 2KB and less than 8KB (inclusive):
find . -type f -size +2047c -size -8193c
No comments:
Post a Comment