HP-ux: Script edit

Hallo Friends,

I have written a script which goes through different directories deleting files but I think there is a shorter way I can do this please help.

#!/bin/ksh

#set -x

cd /minotaur/Data/CFD_Input/E_CIF
cd 051
for files in 2008*
do
rm -rf $file
done
#
cd ../052
for files in 2008*
do
rm -rf $file
done
#
cd ../053
for files in 2008*
do
rm -rf $file
done
#
cd ../054
for files in 2008*
do
rm -rf $file
done
#
cd ../055
for files in 2008*
do
rm -rf $file
done
#
cd ../056
for files in 2008*
do
rm -rf $file
done
#
cd ../057
for files in 2008*
do
rm -rf $file
done
#
cd ../058
for files in 2008*
do
rm -rf $file
done
#
cd ../059
for files in 2008*
do
rm -rf $file
done
#
cd ../060
for files in 2008*
do
rm -rf $file
#END OF SCRIPT#

As your are searching for one single pattern "2008*" it should be easier like this...

as per your case...
cd /minotaur/Data/CFD_Input/E_CIF
find . -name "2008*" | xargs rm -f

that should delete all the files matching the pattern given.

-ilan

Hallo Ilan,

I tried the script you wrote for me but It is not deleting some of the files. I checked the permissions on the files and they are rw-rw-rw. Is there another way I can force a deletion?

can you post the file name which were not deleted?

-ilan