Re: Simple Script for Linux or OS X


Subject: Re: Simple Script for Linux or OS X
From: Rob Lineweaver (rbline@wm.edu)
Date: Wed May 02 2001 - 20:41:53 EDT


On 02 May 2001 17:39:18 -0500, Heath Henderson wrote:
> Hello all, I am in need of a simple Perl script (I am going to attempt it I
> think)
>
> That cleans our users Home directories out, but leaves the Directory itself
> intact and untouched. I want to run this script at the Home directory level
> and have it go 1 level deep and clean out the contents to start fresh next
> school year. It would be nice as well if it was at all possible to set it
> so that the script only looks at accounts that start with a number (It would
> leave our teacher's accounts untouched).
>

Heath,

I think something simpler, like:

rm -rf [0-9]*/*

is what you want. No need to create a PERL script to do something that
regular expressions can do.

To delete files and folders in a user's directory starting with a dot,
you might have to add another expression:

rm -rf [0-9]*/* [0-9]*/.[A-z]*

But definitely test your commands against data that doesn't matter
before applying it to the real user directories! You can also test with
the -i option to rm. The above commands do leave the first-level (user)
directories in place.

hope this helps,

Rob Lineweaver
:)



This archive was generated by hypermail 2b28 : Sun Oct 14 2001 - 03:04:39 EDT