Re: [K12OSN] delete files by gid?

Eric Harrison (eharrison@mail.mesd.k12.or.us)
Sat, 9 Mar 2002 18:43:53 -0800 (PST)


On Fri, 8 Mar 2002, Jeff Davis wrote:

>Can anyone tell me how to delete files by group ID?

This is a bit convoluted, but it happens to be my favorite way of 
doing it...

As an example, this command will delete all files with group id 500
in /home and it's subdirectories:

	find /home -gui 500 -exec rm -v \{\} \;

(yes the " \{\} \;" at the end needed to be typed exactly like that)

A slightly less convoluted command is:


	find /home -gui 500 -print0 | xargs -0 rm -v

"-exec rm -v \{\} \;" and "-print0 | xargs -0 rm -v" basically do the
same thing, but the later is less typo-prone ;-)

The "find" command is hard to learn, but amzingly useful once you do.
The default behavor is just to print the name of the files it finds,
so you can saftely expermient with it before trying to use it to do
something as dangerous as removing files...

	find /home -gui 500

Another tip with find is the "-type" switch, "find /home -type f" would
find all of the files in /home and "find /home -type d" would find all
of the directories in /home. Need to find the directory named "foo" 
somewhere in /var? No problem: "find /var -type d -name foo"

-Eric

>Thanks,
>
>-Jeff
>
>Jefferson K. Davis
>Technology and Information Systems Manager
>Standard School District
>1200 North Chester Ave
>Bakersfield, CA  93308
>USA
>661-392-2110 ext 120
>



_______________________________________________
K12OSN mailing list
K12OSN@redhat.com
https://listman.redhat.com/mailman/listinfo/k12osn
For more info see