LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to show size of files in FIND command (https://www.linuxquestions.org/questions/linux-general-1/how-to-show-size-of-files-in-find-command-546659/)

packets 04-17-2007 01:10 AM

how to show size of files in FIND command
 
Hi to all!

how can i show the size of files if I use the FIND command? Below is the ex:

find /home/*/Maildir -size 5M -type f

It shows the filename with 5M files size but doesn't print its size.

I read the man page but could not locate the one I'm looking for.

TIA

wjevans_7d1@yahoo.co 04-17-2007 01:44 AM

The man page you want is

Code:

man find
Look at the -printf and -print options. You want something like this:

Code:

find /home/*/Maildir -size 5M -type f -printf "%s " -print
Hope this helps.

packets 04-17-2007 02:05 AM

thanks! Now i know what's wrong in my print command

Junior Hacker 04-17-2007 04:24 PM

If you want to see all files above 5M, precede the size with a (+) "+5M", to see all files below, (-), with the command you originally used, you will only see files exactly 5M.

packets 04-17-2007 08:20 PM

However the problem is when I search for -size 5M, it also shows the 4.xM files. Is there a possibility that it only shows all 5.xM files?

BTW: this is my command

find /home/*/ -size 5M -type f -exec du -h {} \; OR

find /home/*/ -size 5M -type f -print0 | xargs -0 du -h

Junior Hacker 04-17-2007 10:49 PM

By rights it is supposed to show what you specify. Even with the (-h) option after du. The (M) in the size is for a true megabyte.
This is from the find man pages:
Code:

Numeric arguments can be specified as

      +n    for greater than n,

      -n    for less than n,

      n      for exactly n.



All times are GMT -5. The time now is 10:27 PM.