This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: find -exec oddity




Randall R Schulz wrote:

Ken,

At 16:38 2003-07-07, Ken Dibble wrote:

Ok, I'm an idiot.  I've looked in the FAQ, searched the mail lists
and checked sundry Unix sources (no, not the source code).


Well, I doubt greatly that you're an idiot. Confusion is the prelude to enlightenment, after all...

(Compare that with Eudora whose "mood watch" feature seems to think the first sentence of the previous paragraph is some kind of insult!)


However, we'd all appreciate it if you'd figure out how to use your mail client to make sure text attachments are not placed in-line with the message content. Not to do so defeats the purpose of attaching the "cygcheck" output, which is to make list searching meaningful by preventing the false hits that occur because of all the package and file names that are included in the cygcheck output.



I can't make sense of this.

$ find ./ -mtime -1  -print | wc -l
   55

$ find ./ -mtime -1 -ls | wc -l
   55

$ find ./ -mmin -1440 -ls | wc -l
   55

$ find ./ -mtime -1  -exec ls -l  '{}' \; | wc -l
 2046


Look carefully at the man page for find where the "-ls" option is described. It says that "-ls" is equivalent to running "ls" with the options "-dils". The salient option here is "-d" which suppresses the listing of a directory's contents when a directory is an explicit argument to ls. You're not including "-d" in your invocation of ls, so every directory produced by find contributes its entire contents to the output of ls that is subsequently counted by "wc -l".


$ find ./ -mtime -1  -exec ls -l  {} \; | wc -l
 2046

$ find ./ -mmin -1440  -exec ls -l  {} \; | wc -l
 2046


and just for grins....


$ find ./ -print | wc -l
31701

$ find ./ -mtime -10 -print | wc -l
  285

$ find ./ -mtime -100 -print | wc -l
15590

The oddity (bug?) appears to be tied to -exec somehow.


No. The "-exec" option is doing just what you ask and just what it should.


Attached is cygcheck -c -v -s.


As above.


I can't attach the file lists (unpiped find output) as the message size then exceeds 100K and the redhat mailserver bounces it.


No matter. It's not needed.


Any help would be appreciated.


I hope my assumption about the problem is correct (file count discrepancies), since you didn't really say what it was that perplexed you.


My mistake on the attachment, it was originally sent as an attachment, along with the file lists, unfortunately the whole message bounced for size.


Your assumption about directories is a good guess, however seemingly only partially correct.

Here is the output today:

$ find ./ -mtime -1  -print
./
./files to backup.txt
./idiot.txt


and


$ find ./ -mtime -1 -print -exec ls -l '{}' \;
./
total 6195
drwx------+ 3 Ken Dibb None 0 Jun 25 07:19 Ad Aware
-rwx------+ 1 Ken Dibb None 981 Apr 22 09:34 Belarc Advisor Current
rofile.txt
drwx------+ 3 Ken Dibb None 0 Jun 25 07:19 CVS
drwx------+ 2 Ken Dibb None 0 Jun 25 07:54 Corel User Files
drwx------+ 2 Ken Dibb None 0 Jun 25 07:32 DMTEdit
drwx------+ 3 Ken Dibb None 0 Jun 25 07:32 Free Agent
drwx------+ 2 Ken Dibb None 0 Jun 25 07:33 Mac Desktop
drwx------+ 2 Ken Dibb None 0 Jun 30 11:48 My Archives
dr-x------+ 2 Ken Dibb None 0 Jun 25 07:33 My Music
dr-x------+ 2 Ken Dibb None 0 Jun 25 07:33 My Pictures
drwx------+ 2 Ken Dibb None 0 Jan 28 19:28 My eBooks
drwx------+ 3 Ken Dibb None 0 Jun 25 07:21 TransMac
-rwx------+ 1 Ken Dibb None 234752 Apr 19 08:00 all-nbuser-faqs.html
-rwx------+ 1 Ken Dibb None 22672 Apr 24 20:01 alpha roster.wpd
-rwx------+ 1 Ken Dibb None 4295398 May 30 07:21 bad_modem.wav
-rwx------+ 1 Ken Dibb None 5396 Jun 27 11:57 create_studentdata_db.
t
-rwx------+ 1 Ken Dibb None 5365 Jun 14 14:19 create_studentdata_db.
t~
-rwx------+ 1 Ken Dibb None 322424 May 6 13:59 cygwin-xfree-ug.pdf
-rwx------+ 1 Ken Dibb None 81 Mar 30 13:56 desktop.ini
drwx------+ 3 Ken Dibb None 0 Jun 27 02:36 disclib
-rwx------+ 1 Ken Dibb None 6336 Apr 9 10:13 dish_list.rtf
drwx------+ 2 Ken Dibb None 0 Jun 25 07:32 dmtlink
-rwx------+ 1 Ken Dibb None 356 Jun 27 12:26 drop_data.txt
-rwx------+ 1 Ken Dibb None 369749 Jul 1 10:20 eclipse-overview.pdf
-rw-r--r-- 1 Ken Dibb None 55 Jul 7 14:02 files to backup.txt
drwx------+ 2 Ken Dibb None 0 Jun 25 07:33 ftp commander
-rwx------+ 1 Ken Dibb None 301 Jul 6 20:29 ftp_scripts.txt
-rwx------+ 1 Ken Dibb None 828 Jul 7 12:35 idiot.txt
-rwx------+ 1 Ken Dibb None 33768 May 30 07:43 javalicious.pdf
-rwx------+ 1 Ken Dibb None 438533 May 31 10:17 jfreereport-0.8.3-intr
pdf
-rwx------+ 1 Ken Dibb None 10874 Jul 6 06:14 martin.zip
-rwx------+ 1 Ken Dibb None 98 Jun 30 17:54 md5s.txt
-rwx------+ 1 Ken Dibb None 1728 Apr 8 20:30 me_startup.rtf
drwx------+ 2 Ken Dibb None 0 Jun 25 07:33 mysql
-rwx------+ 1 Ken Dibb None 117368 Apr 24 08:11 registry.pdf
-rwx------+ 1 Ken Dibb None 183296 Jan 1 2003 retirement.xls
-rwx------+ 1 Ken Dibb None 55431 Apr 24 20:00 rosterS3.wpd
drwx------+ 2 Ken Dibb None 0 Jun 25 07:38 saved snood games
-rwx------+ 1 Ken Dibb None 2752 May 24 18:44 serial.txt
-rwx------+ 1 Ken Dibb None 6388 Jun 8 07:59 server.log
-rwx------+ 1 Ken Dibb None 214643 Jun 1 09:46 sqlj_ug.htm
drwx------+ 2 Ken Dibb None 0 Jun 25 07:23 sqlj_ug_files
./files to backup.txt
-rw-r--r-- 1 Ken Dibb None 55 Jul 7 14:02 ./files to backup.txt
./idiot.txt
-rwx------+ 1 Ken Dibb None 828 Jul 7 12:35 ./idiot.txt


and finally...


$ find ./ -mtime -1 -print -exec ls -ld '{}' \;
./
dr-x------+ 19 Ken Dibb None 0 Jul 7 14:43 ./
./files to backup.txt
-rw-r--r-- 1 Ken Dibb None 55 Jul 7 14:02 ./files to backup.txt
./idiot.txt
-rwx------+ 1 Ken Dibb None 828 Jul 7 12:35 ./idiot.txt




As you can see, there are indeed some directories, but a whole bunch of files
which shouldn't be there as well.


The big question now is why are some files considered directories?


Thanks again, Ken




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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]