[X-Unix] question about 'find'

Charles Howse chowse at charter.net
Sat Nov 26 22:25:19 PST 2005


> Charles Howse wrote on Saturday, November 26, 2005:
> 
>> $ 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?
> 
> The semicolon syntax is clearly documented in each argument that takes a
> variable number of arguments:
> 
>      -exec utility [argument ...];
>              ...  Optional arguments may be passed to the utility.
>              The expression must be terminated by a semicolon (``;'').
>              ...
>      
>      ...
> 
>      -execdir utility [argument ...];
> 
>      -ok utility [argument ...];
> 
>      -okdir utility [argument ...];
> 
>      ...
> 
> The fact that you have to escape a semicolon on the command line is an issue
> with the shell you are using, not find. Although that fact is still noted in
> find's man page:
> 
>   BUGS
>      The special characters used by find are also special characters to many
>      shell programs.  In particular, the characters ``*'', ``['', ``]'',
>      ``?'', ``('', ``)'', ``!'', ``\'' and ``;'' may have to be escaped from
>      the shell.
> 
>> If I missed it in 'man find', please point me to the correct section.  :-)
> 
> Man pages are sometimes hard to read, but after this many years the core ones
> are pretty complete, having been picked over by a thousand software engineers.

I failed to read the BUGS section!  That's where I missed it.
Thanks James.





More information about the X-Unix mailing list