[X-Unix] question about 'find'

Xavier Noria fxn at hashref.com
Sun Nov 27 00:57:26 PST 2005


On Nov 27, 2005, at 4:56, Albert Lunde wrote:

> On Sat, Nov 26, 2005 at 09:24:35PM -0600, Charles Howse wrote:
>> $ find ~/bin -name \*.sh -maxdepth 1 -perm 0644 -exec chmod 744 {} \;
>>
>> This works as expected (I found the '\;' part on a web site), but  
>> I'm not
>> sure why I have to use the '\' as the next-to-last character.
>> Can't find anything about it in 'man find'.
>> Can anyone enlighten me?
>> If I missed it in 'man find', please point me to the correct  
>> section.  :-)
>
> The semicolon is the delimiter for the end of the command being run
> by "-exec", the backslash is necessary to quote it and keep it
> from being interpreted as by the shell running "find".

In fact, unless I want -exec to behave as a boolean test that  
modifies the list of files "founded", the way -name does, I use find 
(1) for finding the list of files I am interested in, and execute  
what I want afterwards in a separate command. For instance like this:

    $ find ~/bin -name '*.sh' -maxdepth 1 -perm 0644 | xargs chmod 744

I find this much more clear.

-- fxn



More information about the X-Unix mailing list