problem with find's -size and -exec options

j. k. colligan jkevinc@gmail.com
Mon May 14 22:30:00 GMT 2012


Friends -

I just noticed a difference in behavior between Cygwin's "find" and
the one in Linux, or
so it seems.

I was trying to locate files smaller than a given size, and thus ran

    find . -size -4000c

That worked, and listed the file names only for files < 4000 bytes in
size.  But if I run

    find . -size -4000c -exec ls -l {} \;

it turns out that *all* files are listed!  (Plus the small ones at the
end of the list.)  This
surprised me.  In other similar cases I've run in the past, the
earlier-in-the-command-line
filters took effect before the exec.

The Linux version of "find" doesn't operate that way:  in the latter
case, only the "small"
files are passed to ls.  And if one replaces "-4000c" with "+4000c",
it works as I'd expect.

And yeah, I tried escaping that minus sign for the Cygwin shell, a la

    find . -size \-4000c -exec ls -l {} \;

Same unexpected (to me) result.  Am I way outta whack here, of is this
a real problem?
Thanks!

cheers,
j. kev
jkevinc@gmail.com
Monday, 2012.05.14 @ 1830 EDT

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list