delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/05/14/18:31:00

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Mon, 14 May 2012 18:29:57 -0400
Message-ID: <CAPt61RQ7Cqm2h0wOE0EdqF712Gw7rBbSa+41ZQwG_y4E8JATsQ@mail.gmail.com>
Subject: problem with find's -size and -exec options
From: "j. k. colligan" <jkevinc AT gmail DOT com>
To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q4EMUvdL032331

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 AT gmail DOT 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019