Deleting old directries


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting old directries
# 1  
Old 04-11-2006
Deleting old directries

All

I want to delete all directories which are modified or created two days before in AIX.

Thanx in advance

Regards
Deepak Xavier
# 2  
Old 04-11-2006
Try something like this:
Code:
#!/bin/ksh
old=$(find /path/to/directory -type d)
for file in `echo $old`
do
      newfiles=""
      newfiles=$(find $old -type f -mtime -2)
      if [ -z $newfiles ] ; then
           rm -f -R $file
      fi
done

You really should consider this carefully BEFORE you run it. Make absolutely sure there are no system files and no directories like /var/tmp in the path. Then be sure you have a full backup.

Because you asked how to do this I'm assuming you're new to this, which is why I'm giving you warning.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

2. Shell Programming and Scripting

deleting lines in ex

Hello, im using ex to manipulate some text. Im trying to delete all the lines except those on which a certain regex can be found. the important part of the script: ex temp << 'HERE' g/regex/p HERE this command prints the lines I want to end up with, but it doesnt delete the others.... (2 Replies)
Discussion started by: drareeg
2 Replies

3. Solaris

Deleting printing everywhere

I am in a prison system with a standalone (no internet connection) Solaris 8 network using Sun-Rays for clients (so no software is on the client side). We are finding a problem where inmates are using the print-to-file function to be able to rename folders everywhere on the server, meaning they are... (1 Reply)
Discussion started by: ixeye
1 Replies

4. Shell Programming and Scripting

Deleting the Last value from a file

How do i use SED command to replace the last existance of ',' with a blank value OR CUT can also do?? Eg --> aaa,aaad,fsdfde, I want to replace it with aaa,aaad,fsdfde Thanks in Advance (7 Replies)
Discussion started by: theeights
7 Replies

5. Shell Programming and Scripting

deleting when nothing is there

Hey I know how to use grep to eliminate a row when nothing there is a character that I dont want. But I encountered a problem where there is nothing there. Heres my example: Nam1 Nam2 Year Nam3 Month So for Nam1 there is nothing in the second column so I want to delete it... so... (1 Reply)
Discussion started by: kylle345
1 Replies

6. UNIX for Dummies Questions & Answers

Deleting every other Line in VI

Hello, How would one delete every other two lines using VI? For example, I have the following 8 lines: Line1 Line2 Line3 Line4 Line5 Line6 Line7 Line8 And wish to only delete lines 3-4 and 7-8. Is there a certain pattern which would make this easier? Thank you, -Jahn (8 Replies)
Discussion started by: Jahn
8 Replies

7. UNIX for Dummies Questions & Answers

df -k and deleting files

hi everybody, urgently need solutioin aftet i execute the command df -k, i get to see al the memory status blah blah if some file system has 95% full then what should i do and any help on how and what to do ? help really appriciated. cheers (4 Replies)
Discussion started by: ajayr111
4 Replies

8. UNIX for Dummies Questions & Answers

deleting all the sub directories

hello., i am creating a certain sub directories as apart of my requirement, and then later on i have to delete all those sub directories.. ____________________________________________________ DIR1="/home/pavi/cvs/20071426/TEMP" echo " DIR1 is : " $DESTDIR1 echo... (2 Replies)
Discussion started by: pavan_test
2 Replies

9. Shell Programming and Scripting

Deleting by ID

Need to delete records from a text file. Very new to this and am using pico. The only way i can think of doing this is to generate an ID for every record then tell it to delete that particular ID. First question is how if possible do i give each entry an ID number, the second is would this code... (1 Reply)
Discussion started by: boyler
1 Replies
Login or Register to Ask a Question