Operating System - HP-UX
1825667 Members
4528 Online
109686 Solutions
New Discussion

Re: delete files with deleting subdirectory structure

 
SOLVED
Go to solution
Amit Sathe
Occasional Contributor

delete files with deleting subdirectory structure

Hi ...

My query is how I can delete all the files
from a directory with disturbing or deleting
subdirectory structure ..

Thanks ..
Amit
7 REPLIES 7
V.Tamilvanan
Honored Contributor

Re: delete files with deleting subdirectory structure


Hi,

#rm -R

See man pages of rm.
Amit Sathe
Occasional Contributor

Re: delete files with deleting subdirectory structure

yes but almost 30 directories & subdirectories are there I wanted to keep the structure as it is ..means don`t want to
delete subdirectories
V.Tamilvanan
Honored Contributor
Solution

Re: delete files with deleting subdirectory structure



Hi,

#find / -type f -exec rm {} \;
Bharat Katkar
Honored Contributor

Re: delete files with deleting subdirectory structure

Amit that is the only command "#rm -R " which will delete the entire directory and its subdirectories as well.

If you want to retain the direcotry structure then probably you have to write a script which deletes only files in the subdirectories. For that you really need to workout as per your structure.

You need to know a lot to actually know how little you know
Bharat Katkar
Honored Contributor

Re: delete files with deleting subdirectory structure

Oh great,
Tamil's solution seems to be correct.
You need to know a lot to actually know how little you know
Roberto Polli
Trusted Contributor

Re: delete files with deleting subdirectory structure

Tamil solution is ok!
maybe you want to use
rm -f
instead of
rm
to avoid confirmation for each file.

Peace, R.
Amit Sathe
Occasional Contributor

Re: delete files with deleting subdirectory structure

Thanks tamil ... it works ..thanks a lot ...I think with this ans u r going to join Royalty club..thats great

Amit