How can I list only non-empty files using ls?

How can I list (using ls) all files that are not empty (size > 0) using linux?


Solution 1:

I'd use find dirname -not -empty -ls, assuming GNU find.

Solution 2:

This is a job for find ls is not powerful enough.

find -maxdepth 1 -size +0 -print

-maxdepth 1 - this tells find to search the current dir only, remove to look in all sub dirs or change the number to go down 2, 3 or more levels.

-size +0 this tells find to look for files with size larger than 0 bytes. 0 can be changed to any size you would want.

-print tells find to print out the full path to the file it finds

Edit:
Late addition: You should probably also add the -type f switch above. This tells find to only find files. And as noted in comments below, the -print switch is not really needed.