Operating System - HP-UX
1834595 Members
3844 Online
110069 Solutions
New Discussion

deleting files and directories

 
SOLVED
Go to solution
JIM WECHTER
Occasional Contributor

deleting files and directories

how do you delete a directory and its contents?
do you really have to
cd name
rm *
cd ..
rmdir name

or is there an easier way?
6 REPLIES 6
T G Manikandan
Honored Contributor
Solution

Re: deleting files and directories

to delete a dir

rm -r "directory name"

Just be sure that you are in the right path.
Else it is good to delete in using a absolute path like

rm -r /home1/abc

Also you can forcefully delete

rm -rf /home1/abc


THanks
Alex Glennie
Honored Contributor

Re: deleting files and directories

try rm -R
PIYUSH D. PATEL
Honored Contributor

Re: deleting files and directories

Hi,

Do a rm -rf /data/oracle ( f- forceful )

# rm -i ( Interactive mode - Ask whether you want to delete or not )

Piyush
Peter Kloetgen
Esteemed Contributor

Re: deleting files and directories

Hi,

this is very simple:

rm -r /path/to/directory

rm -rf /path/to/directory

or, to be sure just to delete the files you really want to delete:

rm -ri /path/to/directory

--> asks for confirmation for each file and the directory itself to be deleted

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
PIYUSH D. PATEL
Honored Contributor

Re: deleting files and directories

Hi,

If you delete the files in any directories they you can remove it later using rmdir. But if some more directories are present it would not allow you to remove the directory name thro rmdir.

Piyush
Olav Baadsvik
Esteemed Contributor

Re: deleting files and directories


Hi

Just an advise:

Make a habit of always doing a pwd
before you do an rm -r
One day you will be happy you did it.

Olav