looping

Hi

I have around 100 users in sun server and have default home directory in /usr/home/<username>

I want to clean their home directory time to time to make free space on root, as users generate many output files during usage of application.

My idea is, generate a file with following command
# cd /usr/home
# du -sk * > tmp.dat

Now I want to read one by one record in tmp.dat and pick the user name and execute # rm /usr/home/<username/* command and reach to 2nd record. Loop should be execute till the time tmp.dat not reach to eof().

I am not able to put the thing in loop.

Pls help..

rgds
Ishir

Are you sure that you want to remove all files for all users? If you are, then there is a better way to do this:

cd /usr/home
for homedir in *; do
rm -rf $homedir/*
done

A better way to go about this would be to use the following code:

cd /usr/home;
du -sk *|sort -nr

Use the above snippet to find which users are occupying the largest size and ask these users to purge unwanted files.

Hi

Thnks for your responce.

I don't want to remove all files from all users.

How to keep data of some specific user.

rgds
Ishir

Is there a specific criteria for removing ... You need to eloborate your needs...

Hi All

Thnaks for input ..

I create a script and working very well.

rgds
Ishir