11-15-2010
Deleting a directory that is not empty
I know someone will probably laugh at this question, I probably knew the answer many years ago when I was doing this full time but here goes.....
I have a directory that has many files and sub-directories in it, RMDIR will not delete a directory that is not empty so what is the command to delete a directory that is not empty?
Thanks in advance.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
as of our requiremnt some x no of files will be created from a third party tool ,out of them one or two files will be empty i.e size is 0. so i want to remove those files which are empty.
naming of the files which are created will be like this
abc_.txt 0 size
abc_1.txt 4000 size
abc_2.txt... (1 Reply)
Discussion started by: srivsn
1 Replies
2. Shell Programming and Scripting
Hi,
I have a TEST.dat file. As a clean up process, I have to delete the TEST.dat file if it is empty. Basically, I don't want to delete TEST.dat if it contains anything in it but want to delete TEST.dat if it contains any spaces or nothing in it.
Is there a command to check if the file... (2 Replies)
Discussion started by: rkumar28
2 Replies
3. Shell Programming and Scripting
Hello Gurus,
I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory?... (5 Replies)
Discussion started by: berlin_germany
5 Replies
4. Shell Programming and Scripting
I need the unix command or shell script to delete all the file in current directory and sub directory. (7 Replies)
Discussion started by: kingganesh04
7 Replies
5. Shell Programming and Scripting
To see if a directory is has anything in it, I do this:
if ; then
# do something
fi
But surely there is a more easy-to-read and elegant way. Isn't there? (6 Replies)
Discussion started by: KenJackson
6 Replies
6. Shell Programming and Scripting
Hello Friends,
Im trying to delete empty files in subdirectories with a command. I can find them checking only one directory in each step and then show them with my command like below moreover i could not add removing part:
ls -l */* | awk '{if ($5==0) printf "%3s %2d %s... (5 Replies)
Discussion started by: EAGL€
5 Replies
7. Shell Programming and Scripting
Hello, I'm submitting this thread, because I was looking a way to delete empty directories using find and I found a thread from 2007 that helped me. I have worked from that threat, but I found that the command sent would analyze original directory and may delete it to. I have come up with expanded... (3 Replies)
Discussion started by: lramirev
3 Replies
8. Shell Programming and Scripting
I have the test data with 10 column separated by comma and each column has more than 1000000 rows. Can anyone help me to find empty field in all columns and delete that empty field alone and lift that column up by one row.
Data with empty field:
A74203XYZ,A21718XYZ,A72011XYZ,A41095XYZ,... (7 Replies)
Discussion started by: zooby
7 Replies
9. UNIX for Dummies Questions & Answers
I have a text file that looks like this:
1 rs523634 8.22486
1
1 rs585160 8.22488
1 rs497228 8.2249
1
1 rs600933 8.225
1 rs480106 8.22531
1 rs600199 8.22533
1 rs529015 8.22534
1 rs598894 8.22534
I want to delete the rows with empty... (2 Replies)
Discussion started by: evelibertine
2 Replies
10. Shell Programming and Scripting
Hey, I need help with writing a shell script that deletes empty folders..anyone? :)
Thank you! (5 Replies)
Discussion started by: putukas
5 Replies
RMDIR(2) Linux Programmer's Manual RMDIR(2)
NAME
rmdir - delete a directory
SYNOPSIS
#include <unistd.h>
int rmdir(const char *pathname);
DESCRIPTION
rmdir() deletes a directory, which must be empty.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
ERRORS
EACCES Write access to the directory containing pathname was not allowed, or one of the directories in the path prefix of pathname did not
allow search permission. (See also path_resolution(7).
EBUSY pathname is currently in use by the system or some process that prevents its removal. On Linux this means pathname is currently
used as a mount point or is the root directory of the calling process.
EFAULT pathname points outside your accessible address space.
EINVAL pathname has . as last component.
ELOOP Too many symbolic links were encountered in resolving pathname.
ENAMETOOLONG
pathname was too long.
ENOENT A directory component in pathname does not exist or is a dangling symbolic link.
ENOMEM Insufficient kernel memory was available.
ENOTDIR
pathname, or a component used as a directory in pathname, is not, in fact, a directory.
ENOTEMPTY
pathname contains entries other than . and .. ; or, pathname has .. as its final component. POSIX.1-2001 also allows EEXIST for
this condition.
EPERM The directory containing pathname has the sticky bit (S_ISVTX) set and the process's effective user ID is neither the user ID of the
file to be deleted nor that of the directory containing it, and the process is not privileged (Linux: does not have the CAP_FOWNER
capability).
EPERM The file system containing pathname does not support the removal of directories.
EROFS pathname refers to a directory on a read-only file system.
CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001.
BUGS
Infelicities in the protocol underlying NFS can cause the unexpected disappearance of directories which are still being used.
SEE ALSO
rm(1), rmdir(1), chdir(2), chmod(2), mkdir(2), rename(2), unlink(2), unlinkat(2)
COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-05-08 RMDIR(2)