1753453 Members
6456 Online
108794 Solutions
New Discussion юеВ

rmdir

 
SOLVED
Go to solution
panchpan
Regular Advisor

rmdir

Hello.
Do we have a UX command which deletes directory and its sub-dirs without emptying them?

Thanks
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor
Solution

Re: rmdir

Hi:

> Do we have a UX command which deletes directory and its sub-dirs without emptying them?

I'm not sure I understand your objective. If a *directory* is *not* empty; that is, the directory has files and/or other subdirectories beneath it, 'rmdir' will not remove the directory. You can, however, use 'rm -rf /path_to_directory' to *force* the deletion of the directory and all subordinate objects (files and directories). Perhaps that is what you want done.

Regards!

...JRF...
Denver Osborn
Honored Contributor

Re: rmdir

Can you provide a bit more detail on what you need to do?

I don't see that it's possible to delete a directory and it's sub-dirs w/out out actually "deleting" them.

Do you need to relocate files to another dir then remove the existing directory structure?

-denver
Sandman!
Honored Contributor

Re: rmdir

If you remove a directory all the entries in that directory will be deleted. So no there is NO command that will delete a dir alongwith its sub-dirs without emptying them. The "rm -rf" command will remove a dir alongwith its contents i.e. files and any sub-dirs.

~cheers
Zinky
Honored Contributor

Re: rmdir

find /dirname -depth -type f -exec rm {}\;
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
Zinky
Honored Contributor

Re: rmdir

The above command should maitain the directory structure --- which is I think what out friend Panchalp (from Thailand?) wants.
Hakuna Matata

Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
panchpan
Regular Advisor

Re: rmdir

MANY THANKS !!!
Sandman!
Honored Contributor

Re: rmdir

Could you shed more light on what you are trying to accomplish. Your requirement is confusing.