View previous topic :: View next topic |
Author |
Message |
OdinsDream Veteran
Joined: 01 Jun 2002 Posts: 1057
|
Posted: Sun Nov 10, 2002 12:41 am Post subject: Delete all files belonging to a certain group / owner ? |
|
|
I've got a directory with many, many files. Is there an easy way to delete only the files that belong to a certain group, or to only a certain user? |
|
Back to top |
|
|
styrke n00b
Joined: 09 Nov 2002 Posts: 6 Location: Linköping, Sweden
|
Posted: Sun Nov 10, 2002 1:20 am Post subject: Re: Delete all files belonging to a certain group / owner ? |
|
|
Yes, use find.
find . -type f -group wheel -exec rm \{\} \;
should remove all files in the current directory and all its subdirectories owned by group "wheel". See "man find" for more info.
Note: Use at your own risk! A good idea might be to replace rm with something harmless first, like echo, to see that it works the way you intended. |
|
Back to top |
|
|
OdinsDream Veteran
Joined: 01 Jun 2002 Posts: 1057
|
Posted: Sun Nov 10, 2002 2:17 am Post subject: |
|
|
Great solution! I'll look more into "find", as it looks like this is a great shell-scripting solution for things like this.
Worked like a charm. |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Sun Nov 10, 2002 2:23 am Post subject: |
|
|
A good companion to find is xargs. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
|