[K12OSN] OT Help with file deletion script

"Terrell Prudé Jr." microman at cmosnetworks.com
Thu Oct 25 06:50:27 UTC 2007


Here's a modification that might make it actually run.  Std. "no
guarantees" caveat applies.

#!/bin/sh
cd /home
for userdir in `ls -C1`
do
  echo Working on $userdir...
  cd $userdir
  for deleteme in `ls -C1 -a`
  do
    if [[ $deleteme != 'mail' ]] || [[ $deleteme != '.openwebmail' ]]
    then do
      echo Removing $deleteme...
      rm -ri $deleteme
    done
    else echo "Oops, encountered "$deleteme", not deleting!"
    fi
  done
done


--TP
_______________________________
Do you GNU <http://www.gnu.org>?
Microsoft Free since 2003 <http://www.cmosnetworks.com>--the ultimate
antivirus protection!


Huck wrote:
> for $x in 'ls'
> do
> for $y in 'ls -a'
>   if $y != 'mail' || '.openwebmail'
>      do rm -rf $y
>
>
> something like that?
> of course that won't run..but it's the logical thinking behind it maybe?
>
> --Huck
>
> Jim Kronebusch wrote:
>> I need to purge files out of an old /home server that is only running
>> email now.  I need
>> a script that will run through every user folder on /home and delete
>> every file/folder
>> except a folder named "mail" and a folder named ".openwebmail".  I
>> need those two
>> folders and their contents to remain untouched.  Can anyone help with
>> this?
>>
>> Of course I'll assume all caveats regarding testing first and not
>> hold anyone
>> responsible for data loss :-)
>> Jim
>>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/k12osn/attachments/20071025/ff4a1b5c/attachment.htm>


More information about the K12OSN mailing list