Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command to Delete a Directory

Status
Not open for further replies.

scient

IS-IT--Management
Oct 24, 2007
15
US
Hi guys..

Whats the command to remove the directory and its contents , because
When I try to remove a directory it saying the following msgs

server01/root: /home/county/ > ls
cpu , memory , snap

here above 3 of them are directories and each has bunch of log files and they have no internal directories all
in that directories are files

server01/root: /home/county> rmdir cpu
rmdir: 0653-611 Directory cpu is not empty.

Can u guys tell me the command to remove that directory and contents at a time rather than deleting each and
Every file in that directory first and delete that directory later..

Thank you,

 
The method that I prefer to use for removing directories is this:

cd into directory to be removed
do a recursive delete
cd back one level
remove the directory

or in code
Code:
cd /some/dir
pwd     # verify I am where I think I am
rm -rf *
cd ..
rmdir /some/dir

when doing a recurive delete (rm -rf), be 200% sure you are in the correct location and really mean it. Be another 200% sure if you are doing this as root.

Add a little color to your PUTTY terminal: faq52-6627
 
oh yesss rm -r * is a very dangerous command that will make you stay for weekends restoring your data! Been there! Done that!

Regards,
Khalid
 
And when you get the error message
Code:
Unable to delete unix: file in use
it's party time!

I speak from bitter experience - but I always reckon that unless you've got at lease one similar tale you're not a real admin.

Ceci n'est pas une signature
Columb Healy
 
Oh yes, I've done it. I had just gotten done reviewing this with a junior admin - he asked why I type pwd so much. 10 minutes later, the junior admin did that exact thing I warned him about. He thought I was going to fire him on the spot - just told him to get the tapes, restore and DONT do it again.

Add a little color to your PUTTY terminal: faq52-6627
 
So next week I'm going to make myself an LPAR and rm -rf * the thing, just so I can count me in with you guys. ;-)

I've done my share of repairing these mistakes though.

Better yet, I'm going to load that LPAR with AIX6 and create a WPAR to fool around with...



HTH,

p5wizard
 
thank you guys....

i used rm -rf * ..it deleted all files in the subdirectory ...

once again appreciated your help...

this is good forum..i like it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top