|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
removing files in a given subfolder
Hello, im new to this forum and directly start with a problem... ![]() I have a folder structure like : Code:
/folder/01/1/oldfiles /folder/01/2/oldfiles /folder/02/1/oldfiles /folder/0x/y/oldfiles Every Month a new folder adds automaticly from the system. Now i need an idea how to search for files inside every oldfiles folder and remove files older than 20 days. I can use "find . -mtime +20 -exec rm {} \;" to remove all files older than 20 days. With "ls -lR|grep "\/Oldfiles" i recieve a list of all folders. How can i combine this without big scripting? thanks Andreas
Last edited by vbe; 10-08-2012 at 09:39 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
For example: Code:
find /folder -maxdepth 4 -mindepth 4 -type f -mtime +20 -delete -- Bye |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Sorry, dont ask me why i posted in german..
![]() "your idea sounds nice, but if there is another folder on same level, the files inside will be deleted too." Wirkt verführerisch, jedoch trifft das dann auch auf Ordner zu die evtl auf gleicher Ebene angelegt wurden. Ich würde schon gerne genauer sortieren. Dann bleibt mir doch wohl nur scripten... Last edited by Hugi; 10-08-2012 at 04:51 PM.. |
|
#4
|
|||
|
|||
|
Pardon? I'm sorry, but I don't know a word of German. However Google translator helped me a bit, this time. ![]() I thought it was your case, and that you didn't have any other directories at level 4 in your structure. You could try: Code:
find /folder -maxdepth 4 -mindepth 4 -path "*/folder/0[0-9]/[0-9]/oldfiles/*" -type f -mtime +20 -delete -- Bye |
| The Following User Says Thank You to Lem For This Useful Post: | ||
Hugi (10-09-2012) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
From The UNIX and Linux Forum Rules: You Must Read this Before Posting (emphasis is mine): Quote:
Alister |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
This looks great. Sorry again for the german.
I will test it tomorrow and give you an report. I forget over the years how powerfull the find command in Linux was.. More and more i feel like the stupid windows Administrator i laughed about 10 years ago. ![]() Hugi ---------- Post updated 9th Oct 2012 at 08:53 AM ---------- Previous update was 8th Oct 2012 at 03:53 PM ---------- Quote:
Thank you |
| The Following User Says Thank You to Hugi For This Useful Post: | ||
alister (10-09-2012) | ||
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Thank you for reporting back with your solution. In the future, it may help someone else.
Regards, Alister |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create subfolder within folder in one command | lalitpct | Shell Programming and Scripting | 3 | 05-28-2012 05:03 AM |
| Link multiple files from different subfolder to a new subfolder | total_ysf | Shell Programming and Scripting | 6 | 07-19-2011 04:13 AM |
| Unzip subfolder to some path. | mrwatkin | UNIX for Dummies Questions & Answers | 0 | 11-09-2009 10:19 AM |
| How to Get the count fo files in each subfolder | sanjangr | UNIX for Dummies Questions & Answers | 1 | 10-06-2009 05:30 AM |
| Samba read only subfolder. | sparcman | UNIX and Linux Applications | 0 | 10-05-2009 11:59 AM |
|
|