In a terminal, how can I find files that are bigger or smaller than x bytes?
I suppose I can do something like
find . -exec ls -l {} \;
and then pipe the result to AWK to filter by file size. But shouldn't there be an easier way than this?
|
|
|
Use:
to find files bigger than 4096 bytes. And :
to find files smaller than 4096 bytes. Notice the + and - difference after the size switch. The
|
|||||||||||||||||||||
|
Prints all files that are lesser than or equal to 4096 bytes in size. Simply change the operator and number at the end of this one-liner to change the criteria. The |
||||
|
|
|
Greater than 2000 bytes:
Less than 2000 bytes:
|
|||||||
|
|
AWK really is quite easy for this sort of thing. Here are some things you can do with it in relation to file size checking, like you asked: List files greater than 200 bytes:
List files less than 200 bytes and write the list to a file:
List files of 0 bytes, record the list to a file and delete the empty files:
|
||||
|
|