On Monday 31 March 2003 20:40, Jason Giangrande wrote:
> Does anyone know how to check if a directory is empty?  I tried the
> following:
> if [ -d "/dir/to/remove" -a ! -s "/dir/to/remove" ]; then
>       echo "Removing /dir/to/remove directory."
>       rmdir /dir/to/remove
> else
>       echo "Directory /dir/to/remove is not empty."
> fi
> Even if the directory (in this example "remove") is empty (has no other
> files or folders) the else statement runs, which means the directory
> does not get removed. Any suggestions would be much appreciated.

rm <some_directory> doesn't remove the dir unless its empty...

Arnold

-- 
Hi, I am a .signature virus. Please copy me into your ~/.signature and send me 
to all your contacts.
After a month or so log in as root and do a rm / -rf. Or ask your 
administrator to do so...

Attachment: pgp00000.pgp
Description: signature

Reply via email to