[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Checking if directory is empty in postrm



> However, a new question arises. Will this work in all cases:
> 
> rmdir $LDIR 2>/dev/null && grep -v $LDIR $LDSOCONF >$tmpfile && mv $tmpfile $LDSOCONF || true
> rm $tempfile   # just in case the mv failed, or grep failed partly
> 
> Or is there any trap door I miss?

What if you have a directory LDIR=/etc/foo/bar but there is another
directory called /etc/foo/barbar in $LDSOCONF?  Maybe you should
change the grep command to:

grep -v "^$LDIR\$" $LDSOCONF

so that you match the entire line.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


Reply to: