how to delete files recursively

Hi Folks,

Could you please help me with a command which can deletes file under a particular level?
I have folder structure like below:
/home/ja361203/A/data
/home/ja361203/B/data
/home/ja361203/C/data
/home/ja361203/D/data
/home/ja361203/E/data

what i want is to deleted the all the files under all data folders?
Is it possible to do that?
Please help.
jayatallenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PapertripCommented:
rm -rf /home/ja361203/*/data/*

Open in new window

0
jayatallenAuthor Commented:
thank you for your reply.
is there anyway to see what will be deleted? something like verbose?
or something like we get when we use OK flag with find command.
like :

find ./ type -f -ok rm {} \;

this asks if its Ok to delete a file or not?
0
PapertripCommented:
To have rm prompt you for each file before deleting, add -i to the syntax
rm -irf /home/ja361203/*/data/*

Open in new window

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

PapertripCommented:
Oh on second thought, -f and -i probably won't play well together.
rm -ir /home/ja361203/*/data/*

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
farzanjCommented:
Try this:


rm -f /home/ja361203/{A,B,C,D,E}/data/*

Open in new window

0
icenickCommented:
You mentioned deleting files to a certain depth.

The command "find" has the options maxdepth and mindepth. You can find info regarding those options under here:

http://linux.about.com/od/commands/l/blcmdl1_find.htm

In order to see what rm is deleting, you have to specify the option "v", i.e. verbose. For quick deleting of files, pipe the output of find to "xargs", eg:

find /path/ -maxdepth 4 -mindepth 1 -type f | xargs rm -rv

Open in new window


Good Luck!
0
farzanjCommented:
You can include  -level with your find command.

0
jayatallenAuthor Commented:
thank you guys for your help..all answers are helpful.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.