1834798 Members
2503 Online
110070 Solutions
New Discussion

Re: find -size

 
MikeL_4
Super Advisor

find -size


What is the correct use of the -size parameter to find all files over 500Mb ??

I know this probably sounds trivial but I can't
seem to ge it to work correctly ...

Thanks
9 REPLIES 9
Pete Randall
Outstanding Contributor

Re: find -size

-size 100000000 (I think!)


Pete


Pete
Pete Randall
Outstanding Contributor

Re: find -size

To expand:

1,000,000 one half KB blocks would give you 500,000KB, which should be 500MB.


Pete


Pete
Todd McDaniel_1
Honored Contributor

Re: find -size

Here is a great script we use... a local guy wrote this not me... so cant take credit for it.

Syntax is:

bigfiles

It will recursively search for files larger than in as the starting point.

------------- cut here ----------------------
# cat bigfiles

# To find any file over a certain size in a given directory
# Primarily used to locate files which might be running a filesystem out of
# space.
#
# First parameter is the filesystem or directory to begin the search from
# Second parameter is the size of the file, in characters, to find
#

#
if [ $# -eq 2 ]
then
if [ -d $1 ]
then
#ls -l `find "${1}" -xdev -size +"${2}"c -print`
find "${1}" -xdev -size +"${2}"c -print > /tmp/crslist$$
if [ -s /tmp/crslist$$ ]
then
ls -l `cat /tmp/crslist$$`
else
echo "apparently no files that large in "${1}
exit
fi
else
echo "$1 is not a directory...try again"
exit
fi
else
echo "\n\nbigfiles requires 2 parameters..."
echo "\tthe first is the beginning directory"
echo "\tthe second is the size of the file to search for\n\n"
fi
############################################
Unix, the other white meat.
A. Clay Stephenson
Acclaimed Contributor

Re: find -size

The criticxal thing to note is that find -size 100c will find files of exactly 100 characters while find -size +100c will find those above 100 characters. In your case,

find . -type f -size +524288000c ...
will list those over 500MB.
If it ain't broke, I can fix that.
Larry Basford
Regular Advisor

Re: find -size

I would just add the full command to stop crossing mount points. Comes in real handy when you want to only look in one filesystem.

find . -xdev -size +524288000c -depth -exec ls -l {} \;
Desaster recovery? Right !
MikeL_4
Super Advisor

Re: find -size

Thanks for all the help, but if I could ask one more question that I can't seem to get straight in my mind.... how is the -size parameter calculated ??? be it a 200Mb plus file or whatever, how are you coming up with the size parameter ??

Thanks
T G Manikandan
Honored Contributor

Re: find -size

value followed by a c, the size is in bytes.

250MB

find . -size 265000000c -exec ll {} \;
T G Manikandan
Honored Contributor

Re: find -size

250 MB
#find . -size +262144000c -exec ll {} \;


curt larson_1
Honored Contributor

Re: find -size

-size n[c] True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in bytes. and if preceded by +, means greater then.

-size 1 will match 512 bytes
-size 1c will match 1 byte
-size +1 will match greater they 512 bytes