I am looking for a Unix command to print the files with its size. I used this but it didn't work.
find . -size +10000k -print.
I want to print the size of the file along with the filename/directory.
find . -size +10000k -exec ls -sd {} +
If your version of find
won't accept the +
notation (which acts rather like xargs
does), then you might use (GNU find
and xargs
, so find
probably supports +
anyway):
find . -size +10000k -print0 | xargs -0 ls -sd
or you might replace the +
with \;
(and live with the relative inefficiency of this), or you might live with problems caused by spaces in names and use the portable:
find . -size +10000k -print | xargs ls -sd
The -d
on the ls
commands ensures that if a directory is ever found (unlikely, but...), then the directory information will be printed, not the files in the directory. And, if you're looking for files more than 1 MB (as a now-deleted comment suggested), you need to adjust the +10000k
to 1000k
or maybe +1024k
, or +2048
(for 512-byte blocks, the default unit for -size
). This will list the size and then the file name. You could avoid the need for -d
by adding -type f
to the find
command, of course.