We help IT Professionals succeed at work.
Get Started

Creating a script to delete multiple files in multiple dirs.

16582 asked
Last Modified: 2013-12-06
Currently I have an HP-UX 11i (11.23).  I'm running the command below to remove files / directories older than today, the problem I'm having is creating a script to execute in multiple directories.

root@bhux1#  find /ds1/in_dcm -type f -mtime +1 -exe rm -f {} \;

The command runs great, the only issue I have is, I must change the directory in the command each time it runs.  Is there  (1) any way do give it a block of directories to remove? (i.e. /ds1/in_dcm is shown but I have ds1 - ds28 and not all are online all the time -- in other words ds1 -ds7 may be online ds8 - ds12 offline and the rest online.)

What I would like to do is have a command or script to move thru all of the directories without having to manually change.  That way I can add it to the crontab for a weekly run.

Watch Question
Data Warehouse / Database Architect
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE