The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help on a perl script to edit file meghana Shell Programming and Scripting 9 05-14-2008 11:42 AM
i want to edit my jsp page using script nsundaram_cse Shell Programming and Scripting 2 08-14-2007 04:16 AM
How to EDIT file using VI in a script bobk544 Shell Programming and Scripting 2 07-25-2007 06:16 AM
Can we edit crontab using a shell script rudrarajumk Shell Programming and Scripting 3 03-31-2005 06:51 AM
Javascript: Edit a script ? perleo Shell Programming and Scripting 1 05-23-2003 03:45 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-15-2008
kekanap's Avatar
Registered User
 

Join Date: Sep 2003
Location: South Africa
Posts: 35
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#
Reply With Quote
Forum Sponsor
  #2  
Old 01-15-2008
Registered User
 

Join Date: Jul 2007
Posts: 76
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
Reply With Quote
  #3  
Old 01-16-2008
kekanap's Avatar
Registered User
 

Join Date: Sep 2003
Location: South Africa
Posts: 35
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?
Reply With Quote
  #4  
Old 01-16-2008
Registered User
 

Join Date: Jul 2007
Posts: 76
Quote:
Originally Posted by kekanap View Post
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0