Re: [Nolug] find folder delete contents

From: John Kosta <johnkosta_at_earthlink.net>
Date: Tue, 13 Dec 2005 17:43:20 -0600
Message-ID: <439F5C98.4010201@earthlink.net>

-ray wrote:
> On Tue, 13 Dec 2005, John Kosta wrote:
>
>> But, if I change the -exec portion to:
>>
>> -exec ls {} \;
>
> And just FYI, find has it's own -ls built in, and is a lot cheaper than
> forking /bin/ls on each file.
>
> find . -ls
>
> ray
>

Good to know.

Well, it turns out that I am still in need of a solution.

The problem is, I don't want to delete the directories, just the
contents of said "cache" directories.

So:
find /path -type d -name "*[Cc]ache*" -print -exec "rm -f {}/*.*" \;

doesn't work, because of M$'s
"Application Data/"

syntax.

In other words, because of the space in the directory name, you end up
trying to delete:

/path/Application

Data/blahblah/Cache/*

You end up with two strings instead of the full path to the file.

Another idea I tried which looked like it would work was:

print . |grep "Cache/" |while read f; do rm $f done;

Again, any spaces in the directory path breaks that (though it does work
if you have a full path and file names without spaces).

So, still scratching my head. I guess I need to make sure I can even
delete this stuff by hand, by putting in the full path with quotes or
something.

--John
___________________
Nolug mailing list
nolug@nolug.org
Received on 12/13/05

This archive was generated by hypermail 2.2.0 : 12/19/08 EST