[K12OSN] OT Help with file deletion script

James P. Kinney III jkinney at localnetsolutions.com
Thu Oct 25 15:31:22 UTC 2007


On Thu, 2007-10-25 at 10:16 -0500, Jim Kronebusch wrote:
> On Thu, 25 Oct 2007 02:50:27 -0400, Terrell Prudé Jr. wrote
> > 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
> 
> I get this error when run:
> 
> ./homedir_purge: 10: Syntax error: "do" unexpected
> 
> Ideas?

Remove the "do" from line 10 and the "done" from line 13. The
if ...
then
.
.
.
else
.
.
fi

is sufficient grouping.
> 
> Jim
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by the Cotter Technology 
> Department, and is believed to be clean.
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
> 
-- 
James P. Kinney III          
CEO & Director of Engineering 
Local Net Solutions,LLC        
770-493-8244                    
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics)
<jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/k12osn/attachments/20071025/8ec177bb/attachment.sig>


More information about the K12OSN mailing list