deleting files and folders matching criteria


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting deleting files and folders matching criteria
# 1  
Old 06-24-2007
deleting files and folders matching criteria

Hello,

I'm spendind hours trying to figure out how a script could remove files and folders older than 30days in a given volume (/dataVolumes/Booba.1.0).
Within this volume, all users have their personal folder that starts with "RC-..", so the script should skip them for deletion.
I will integrate this script to a longer one, that periodically does the maintenance (fsck and defragfs) on the server.

Any help is more than welcome !
THANKS,
H.
# 2  
Old 06-24-2007
You can do something like that :
Code:
find dataVolumes/Booba.1.0 \( -type d -name 'RC-*' -prune \) -o -mtime +7 | xargs rm

Read the find man pages.
# 3  
Old 06-25-2007
Data deleting files and folders matching criteria Reply to Thread

Hi Jean-Pierre,
thanks for your answer. Unfortunately, this script doesnt delete all the files and folders.. for some unknown reason, it says:

rm: cannot remove directory dataVolumes/Booba.1.0/lanoo/.Acro26992
rm: cannot remove directory dataVolumes/Booba.1.0/lanoo/.Acro26992/.rsrc
rm: cannot remove directory dataVolumes/Booba.1.0/lanoo/.rsrc
rm: cannot remove directory dataVolumes/Booba.1.0/testerwin
rm: cannot remove directory dataVolumes/Booba.1.0/testerwin/.rsrc
rm: cannot remove directory dataVolumes/Booba.1.0/imagopdf2400
rm: cannot remove directory dataVolumes/Booba.1.0/imagopdf2400/.rsrc
rm: cannot remove directory .....

any idea ?
Merci !
H.
# 4  
Old 06-25-2007
As u r deleting the directory, u hv to give recursive option. So with little modification it will work.

find dataVolumes/Booba.1.0 \( -type d -name 'RC-*' -prune \) -o -mtime +7 | xargs rm -rf
# 5  
Old 06-25-2007
Data deleting files and folders matching criteria

It is still not working Smilie

#stop atalk and Legato
echo "Stopping atalk . . ." |tee -a $LOGFILE
/usr/local/es/stop-atalk now >/dev/null 2>&1
echo "Stopping NFS . . ." |tee -a $LOGFILE
stopsrc -g nfs >/dev/null 2>&1
echo "Stopping Samba . . ." |tee -a $LOGFILE
/comp/version/scripts/stopsmb >/dev/null 2>&1

#remove files older than 30days in dataVolumes/Booba.1.0,except 'RC-*' folders
find /dataVolumes/Booba.1.0 \( -type d -name 'RC-*' -prune \) -o -mtime +7 | xargs rm -rf
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Merge two files based on matching criteria

Hi, I am trying to merge two csv files based on matching criteria: File description is as below : Key_File : 000|ÇÞ|Key_HF|ÇÞ|Key_FName 001|ÇÞ|Key_11|ÇÞ|Sort_Key22|ÇÞ|Key_31 002|ÇÞ|Key_12|ÇÞ|Sort_Key23|ÇÞ|Key_32 003|ÇÞ|Key_13|ÇÞ|Sort_Key24|ÇÞ|Key_33 050|ÇÞ|Key_15|ÇÞ|Sort_Key25|ÇÞ|Key_34... (3 Replies)
Discussion started by: PK29
3 Replies

2. UNIX for Dummies Questions & Answers

Rsync not deleting destination files/folders

Hi All, I want delete all files from destination folder. I am trying below commands rsync -avFF --delete-after /home/vizion/source/ /home/vizion/destination/ I need to be delete all file/fodders from destination Any body have idea ? Please correct me. (3 Replies)
Discussion started by: Chenchireddy
3 Replies

3. Shell Programming and Scripting

Renumber position 88-94 inside all files matching criteria inside folder

There are 4 files inside one folder matching criteria i.e. File name = ABCJmdmfbsjopXXXXXXX_mm-dd-yyyy_XXX.data Here is the Code which find the files matching criteria:- TS=`date +"%m-%d-%Y"`| for fname in `find . -name "ABCJmdmfbsjop???????_${TS}*.data"` do # Matching File Processing Code.... (1 Reply)
Discussion started by: lancesunny
1 Replies

4. Shell Programming and Scripting

changing the file-name in a directory for all files matching a particular criteria

i have a directory which consist of multiple files out of which there are some files that has -e in their name. I want to write a script that will change all those file-name to -l example there are some files with name : file1-e.wav file2-e.wav file3-english-e.wav file-4-e.wav ... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

5. Shell Programming and Scripting

Find and replace string matching criteria

Dear Friends, I am looking for a way to replace a string (multiple lines) starting with something and ending with something (these two values do not change) with blank. Basically I want to delete this code injection accross many sites and folders. Search Code (across files and folders) that... (2 Replies)
Discussion started by: libras
2 Replies

6. UNIX for Dummies Questions & Answers

How to fetch files right below based on some matching criteria?

I have a requirement where in i need to select records right below the search criteria qwertykeyboard white 10 20 30 30 40 50 60 70 80 qwertykeyboard black 40 50 60 70 90 100 qwertykeyboard and white are headers separated by a tab. when i execute my script..i would be searching... (4 Replies)
Discussion started by: vinnu10
4 Replies

7. Shell Programming and Scripting

Archive files to different target folders based on criteria

Hi All, I am creting archive script in which i need to split the source file's to different target folder's based on the input file name first character. Input1.txt -- will contains file names that are needs to be Archive. Input1.txt A1213355 B2255666 C2254555 A6655444 C5566445 ... (2 Replies)
Discussion started by: kmsekhar
2 Replies

8. Shell Programming and Scripting

Deleting files without folders.

How can I delete all the files in subfolders without folders (preserving directory scructure). P.S. I have a huge variety of computer books organized in subfolders (admin web hardw programming_langs) .. but I don't need them - the only way to know something now is GOOGLE (I've realized now)...... (1 Reply)
Discussion started by: Xcislav
1 Replies

9. Shell Programming and Scripting

making a list matching certain criteria in bash...

Hello everyone!I am trying to make a mail list(a simple .txt file)in which i put certain records that match specific criteria. Let's say that i have a(sorted by last column file)like this one: 0100567 Bla1 Lala1 100 1234567 Bla2 Lala2 80 8769029 Bla3 Lala3 70 1001007 ... (0 Replies)
Discussion started by: bashuser2
0 Replies

10. AIX

Simultaneous searching for files (names matching certain criteria) in several directo

Hello everyone, My OS is AIX 5.2 I would like some help in getting command syntax that does the following: 1. Searches simultaneously several directories downward; 2. Checks every subdirectory in each directory (and so on...) for file names that contain certain characters such as “~”, start... (0 Replies)
Discussion started by: Hopeful
0 Replies
Login or Register to Ask a Question