Matthias Czapla wrote:
On Thu, Jul 15, 2004 at 07:14:30AM +0800, John Summerfield wrote:
Since he specifically said he wants to use mdsum, it's clearer to use the program he said he wants to use.Hu? I used cat solely for the purpose of showing how to executefind ~ -type f -exec cat {} \;This fails because
cat doesn't check anything - it just copies all files to stdout
It doesn't handle files whose names contain spaces
arbitrary commands recursively for each file in a directory tree.
How exactly does cat care about its argument containing spaces?
Generally true but in this case the specific command executed by find is irrelevant.
Try it and see what happens.
Ok:
<[EMAIL PROTECTED] ~/tmp>find a -type f -exec echo .{}. \; .a/b b/file. .a/ b/ c c/file. .a/bb b /file with spaces. .a/file with spaces. <[EMAIL PROTECTED] ~/tmp>find a -type f -exec md5sum {} \; d41d8cd98f00b204e9800998ecf8427e a/b b/file d41d8cd98f00b204e9800998ecf8427e a/ b/ c c/file d41d8cd98f00b204e9800998ecf8427e a/bb b /file with spaces d41d8cd98f00b204e9800998ecf8427e a/file with spaces
Where's the problem?
The problem is that fragments of file names separated by spaces are indistinguishable from filenames separated by spaces.
This is only true when the command line is being split into words, e.g.
by the shell. find's '{}' parameter is given to the command literally
as one of the strings in argv[], it is *not* parsed for token delimiter
characters or anything.
<blush>
I don't use -exec on find any more because it's slow. When you pipe the names into xargs as I do, then spaces cause the problem I described.
For slowness, consider this: [EMAIL PROTECTED]:~$ find ~ -type f | wc -l 886076 [EMAIL PROTECTED]:~$ and this: [EMAIL PROTECTED]:~$ find ~ -type f -print0 | xargs -0 | wc -l 3990 [EMAIL PROTECTED]:~$
--
Cheers John
-- spambait [EMAIL PROTECTED] [EMAIL PROTECTED] Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

