Computing.Net > Forums > Unix > Korn shell script help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Korn shell script help

Reply to Message Icon

Name: siya
Date: January 11, 2006 at 07:12:53 Pacific
OS: xp
CPU/Ram: 256
Comment:

Hi,

I need some help in writing this script which deletes ONLY SPECIFIC directories in a folder structure, which are 90 days old.

Directory structure is something like this:

1. Orders directory is having Incoming and Outgoing directories.
2. Each Incoming and Outgoing directories is having several Store1, Store2, Store3...dirs.
4. Store1 dir is having Today, Store1_20051007_093658, Store1_20060110_111149...dirs.
5. Similar with Store2,Store3...each will have Today, Store2__20060110_111149 dir under Store2...and Today, Store3_20060110_111149 dirs under Store3....

This script has to delete only Store1_20051007_093658, Store2__20060110_111149...directories which has timestamp and which are 90 days old.

Orders, Incoming, Outgoing, Store1,Store2...dirs can be 90 days old and they should not be deleted.

I am doing something like this, but it's not working.

find /Orders/* -type d -mtime +90 |
grep -i [[:alnum:]]_[0-9]*

Any help is highly appreciated.. Thanks, Siya



Sponsored Link
Ads by Google

Response Number 1
Name: siya
Date: January 11, 2006 at 08:15:37 Pacific
Reply:

I just tried with this command and looks like it's working: Please let me know if you see a better way other than this:

find /Orders/* -type d -mtime +90 -name "*_*" -exec rm -rf {} \;


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Korn shell script help

korn shell script help www.computing.net/answers/unix/korn-shell-script-help/3815.html

Korn Shell script help please!! www.computing.net/answers/unix/korn-shell-script-help-please/4345.html

Korn shell script help ! www.computing.net/answers/unix/korn-shell-script-help-/7240.html