Patch to find(1) to find large files.

David Elliott dce at hammer.UUCP
Sat Jun 8 03:48:53 AEST 1985


In article <663 at lsuc.UUCP> dave at lsuc.UUCP (David Sherman) writes:
>Foo, grumble and feh! find(1) already has a "-size" option.
>If you want to compare size against another file, it's
>trivial to write a one-line awk script which feeds the right
>information to find(1).
>
>Dave Sherman
>The Law Society of Upper Canada
>Toronto
>-- 
>{  ihnp4!utzoo  pesnta  utcs  hcr  decvax!utcsri  }  !lsuc!dave


Put your money where your mouth is, Dave. The above note would
imply that you can write an awk script that would generate a
find command that looks something like this:

	find dir \( -size n -o -size n+1 -o -size n+2 ... \)

How big can a file get?

Now, take the following predicates:

	-size  is to -bigger
		as
	-mtime is to -newer

Your statement would imply that -newer can be replaced by an awk
script to generate information for -mtime.

Wrong! The missing quality here is granularity. If you read the manual
page for find, you will see that -mtime is measured in days, whereas
-newer is a true relative comparison. The -size primary is measured
in blocks, whereas -bigger is again a true relative comparison.

In other words, -bigger will find that a 4-byte file is bigger than
a 3-byte file, whereas -size can not be so granular.

Now, I agree that you could write -bigger as something like:

	find dir -print | print_if_bigger_than file

(where 'print_if_bigger_than' is a program that prints the names of
the files that are bigger), but this is very slow (eats machines
for lunch and process slots for dinner) and doesn't give half of the
capabilities that -bigger does.

My only criticism of the -bigger modification is that it would be
nice if its usage was:

	-bigger file	(same as now)
	-bigger number

where the latter would allow an exact number, and possibly K (*1024) and
M (*(1024*1024)) as suffixes. Of course, THIS feature is mostly
carried out by the -size option (though -size still isn't as granular).

What we really need is a "find compiler". Do you run find on your machine
every night? Do you know what it has to go through just to find out if
a file is three days old and smaller than 10 blocks or owned by `fred'
or setuid root? This can really chew up the ol' CPU cycles.

			David Elliott
			tektronix!tekecs!dce



More information about the Comp.unix.wizards mailing list