help with command line deletion

Martin Costabel costabel at wanadoo.fr
Wed Apr 18 08:39:38 PDT 2007


Scott Anguish wrote:
> I wonder if the difference here is the shell that you use...

No, it is what has been mentioned before, namely the problem of the 
order of traversal of directories.

> On Apr 17, 2007, at 6:05 AM, David Herren wrote:
> 
>>
>> On Apr 17, 2007, at 11:45 AM, Jyrki Wahlstedt wrote:
>>
>>> one thing you could use, is:
>>> $ find somedir -name '.indelible-info' -exec rm -rf {} \;
>>>
>>> with 'somedir' being a directory name (first a small set, finally 
>>> '/'). Like this no other directories are touched.
>>
>> attempting this returns:
>>
>> voyager2:/Volumes/Data/Applications/Graphics/Graphing Calculator.app 
>> sysadmin$ sudo find ./ -name '.indelible-info' -exec rm -rf {} \;
>> find: .//.indelible-info: No such file or directory

Use either the -d flag:

   sudo find -d ./ -name '.indelible-info' -exec rm -rf {} \;

This tells find to look first at (and kill) the contents of a directory 
and then the directory itself. The default is the other way round which 
leads to the error message.

Or use the -delete flag:

    sudo find ./ -name '.indelible-info' -delete

This is shorter and implies -d.

All this is nicely explained in "man find".

-- 
Martin



More information about the MacOSX-admin mailing list