![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting files based on file name and modified time | ammu | UNIX for Dummies Questions & Answers | 1 | 01-22-2008 08:09 AM |
| how to retrieve original contents of a modified file (modified using vi) | novice100 | UNIX for Dummies Questions & Answers | 3 | 05-31-2007 05:50 PM |
| find files modified in a specific month | omer_ome | UNIX for Advanced & Expert Users | 1 | 07-02-2006 06:43 AM |
| find files modified in a specific month | omer_ome | SUN Solaris | 1 | 07-02-2006 06:38 AM |
| find files modified in a specific month | omer_ome | HP-UX | 1 | 07-02-2006 06:36 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting file with last modified for 1 month
Hello...
Any body, how to delete the files where last modified for 1 month, would you give some example. Sorry, im very newbie in scripting. Thanks. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Assuming you want to delete files last modified prior to 30 days and recrusively in directory $DIR command looks like this
Code:
find $DIR -mtime +30 -exec rm -f {} \;
|
|
#3
|
||||
|
||||
|
find <directory to search from> -type f -mtime +30 -exec rm -f {} \;
Be very sure that the directory contains only files which are not required by the sytem. |
|
#4
|
|||
|
|||
|
this will delete any file that is 30 days or MORE
not exactly 30 days so if you have files like 31 40 50 100 or more they will get deleted too be careful |
|
#5
|
|||
|
|||
|
Thanks
Thanks all
|
|||
| Google The UNIX and Linux Forums |