help with command line deletion

Milo Velimirovic milov at cslab.uwlax.edu
Tue Apr 17 07:27:46 PDT 2007


On Apr 17, 2007, at 9:15 AM, LuKreme wrote:

> On 17-Apr-2007, at 03:15, Michael Maibaum wrote:
>> sudo find / -name '.indelible-info' -exec rm \{\} \;
>
> No, that's just wrong.
>
> \{\} will not work, it is: -exec {} \;

come on now... you cannot exec a directory name.

>
>
> -- In England 100 miles is a long distance. In the US 100 years is  
> a long time

yeah...

sudo find / -type d -name '.indelible-info' -print0 | xargs -0 rm -r

deconstructed:

-type d since we know that we're only interested in directories  
named .indelible-info

-print0 in cast there are any goofy characters in the pathnames,  
matched with the -0 option to xargs

use xargs to avoid the overhead of forking off a process for each and  
every directory found.

use the rm -r command to remove the .indelible-info directories and  
all their contents. (rmdir will only work if the directories are empty.)

--
Milo Velimirović                            <milov at uwlax.edu>
Unix Computer Network Administrator            608-785-6618 Office
ITS Network Services                        608-386-2817 Cell
University of Wisconsin - La Crosse
La Crosse, Wisconsin 54601 USA                43 48 48 N 91 13 53 W
--
"The displacement of the idea that facts and evidence matter by the  
idea that everything boils down to subjective interests and  
perspectives is-second only to American political campaigns-the most  
prominent and pernicious manifestation of anti-intellectualism in our  
time." Larry Laudan, Science and Relativism (1990)




More information about the MacOSX-admin mailing list