HP-ux: Script edit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HP-ux: Script edit
# 1  
Old 01-15-2008
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#
# 2  
Old 01-15-2008
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
# 3  
Old 01-16-2008
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?
# 4  
Old 01-16-2008
Quote:
Originally Posted by kekanap
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

File edit script exceptions how to pass to script

i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add ./script -- add hi ./script --add "hi how are you" now below script with case it is working for... (0 Replies)
Discussion started by: markjohn1
0 Replies

2. Homework & Coursework Questions

Edit the file in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to automate hadoop installation procedure using shell script. It involves go to perticular directory... (3 Replies)
Discussion started by: Abdul Navaz
3 Replies

3. UNIX for Dummies Questions & Answers

UNIX script unable to edit

Hello every one, I am a newbie , I am trying to run the script .sh file , but when I run this, I need this backup file to store at some location called " /A/B " ,but this location should only consist the latest backup file. which mean at any time this location only consists the latest backup... (2 Replies)
Discussion started by: karthik25
2 Replies

4. Shell Programming and Scripting

Shell script to edit a file

Hello, I have a big file in wich I would like to rename inside this exactly the string '_ME' and not rename in case we have 'ABC_MELANGE'. Is there a way to do it by using a shell script? Any tip will be apreciated. The file is like described bellow, after using command more filename : ... (3 Replies)
Discussion started by: Titas
3 Replies

5. Shell Programming and Scripting

Can we edit crontab using a shell script

Hi, Can some one tell me if we can configure the jobs in crontab using a shell script. I know it can be done easily by using "crontab -e", but i just want to know whether we can add a job into the crontab using a shell script. If it can be done, plz suggest the procedure to do it. If it... (6 Replies)
Discussion started by: rudrarajumk
6 Replies

6. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

7. Shell Programming and Scripting

help on a perl script to edit file

Hi, sample file looks like this.. <hp> <name> <detail>adsg</detail> ... ... </name><ft>4264</ft> </hp> I need to edit the last but one line using perl script. I want the format to be .. <hp> <name> <detail>adsg</detail> ... ... </name> (9 Replies)
Discussion started by: meghana
9 Replies

8. Shell Programming and Scripting

i want to edit my jsp page using script

hi I have one jsp file. i want to edit this jsp page using script. This jsp page contains ("insert into employee values('raja', 32, ' ');) i want to add empty column at the end of the line. i.e is that line should be (insert into employee values('raja', 32, ' ', ' ');) (2 Replies)
Discussion started by: nsundaram_cse
2 Replies

9. Shell Programming and Scripting

How to EDIT file using VI in a script

Hello, How would i go about editing a file using VI within a shell script please? Basically, i want to open a file, clear it's contents and save the file. I found this on the web using "ex" but can't seem to get it to work: ex /home/oconnor/TOOLS/UNIXCMDS/test_ex <<eof_ex dd /*i put... (2 Replies)
Discussion started by: bobk544
2 Replies

10. Shell Programming and Scripting

Javascript: Edit a script ?

Hi, i got this script but when i hit reset i loose the times in the form box. Can someone please edit this script so when i hit reset i dont loose the times in the form box's and also have a button to reset everything, including the form boxs <script language="javascript"> // stopwatch... (1 Reply)
Discussion started by: perleo
1 Replies
Login or Register to Ask a Question