Recursive deletion based on owner

Recursive deletion based on owner

Post by KnockKnoc » Sat, 22 Mar 2003 06:27:33



Hi all,

How would I recursivly delete only files that are owned by a certain user?

ie: delete all files owned by John in all subdirectories but not deleting
Mary's

Also I want to leave directories owned by John in tact.

--
"I don't apologize. I'm sorry, but that's just the way I am."
- Homer Simpson

 
 
 

Recursive deletion based on owner

Post by Tim Hayne » Sat, 22 Mar 2003 07:27:30



> How would I recursivly delete only files that are owned by a certain user?

> ie: delete all files owned by John in all subdirectories but not deleting
> Mary's

> Also I want to leave directories owned by John in tact.

You mean like

find . -type f -user John | xargs rm

? ;)

(Adjust to taste; if you have files with whitespace or other whizzy
characters in, make that
           find . <assorted criteria> -print0 | xargs -0 rm
Other filtering critera for `find' are in the fine manual. Read for more.)

~Tim
--

When fact is fiction and                    |http://spodzone.org.uk/
T.V. is reality,                            |

 
 
 

Recursive deletion based on owner

Post by KnockKnoc » Sat, 22 Mar 2003 07:51:54




> > How would I recursivly delete only files that are owned by a certain
user?

> > ie: delete all files owned by John in all subdirectories but not
deleting
> > Mary's

> > Also I want to leave directories owned by John in tact.

> You mean like

> find . -type f -user John | xargs rm

> ? ;)

> (Adjust to taste; if you have files with whitespace or other whizzy
> characters in, make that
>            find . <assorted criteria> -print0 | xargs -0 rm
> Other filtering critera for `find' are in the fine manual. Read for more.)

Yes .. that is exactly what I need. Most appreciated!   |
 
 
 

Recursive deletion based on owner

Post by Bill Marcu » Sat, 22 Mar 2003 19:51:54


On Thu, 20 Mar 2003 14:27:33 -0700, KnockKnock


> Hi all,

> How would I recursivly delete only files that are owned by a certain user?

> ie: delete all files owned by John in all subdirectories but not deleting
> Mary's

> Also I want to leave directories owned by John in tact.

man find
 
 
 

Recursive deletion based on owner

Post by Barry Kimelma » Sat, 22 Mar 2003 23:39:00


[This followup was posted to comp.unix.questions]



Quote:> Hi all,

> How would I recursivly delete only files that are owned by a certain user?

> ie: delete all files owned by John in all subdirectories but not deleting
> Mary's

Since file is owned by John we don't have to worry abolut narry.

    find directory_name -type f -user John -print -exec rm -f '{}' \;

Quote:

> Also I want to leave directories owned by John in tact.

> --
> "I don't apologize. I'm sorry, but that's just the way I am."
> - Homer Simpson

--
---------

Barry Kimelman
Winnipeg, Manitoba, Canada

 
 
 

Recursive deletion based on owner

Post by Stephen M. Du » Mon, 24 Mar 2003 04:47:43


$How would I recursivly delete only files that are owned by a certain user?

man find
--

Quote:>>>----------------> http://www.stevedunn.ca/ <----------------<<<

------------------------------------------------------------------
     Say hi to my cat -- http://www.stevedunn.ca/photos/toby/