LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-09-2012, 10:25 PM   #1
henkoslaw
LQ Newbie
 
Registered: Jun 2012
Posts: 1

Rep: Reputation: Disabled
Bash script to remove files older than x days


How to remove directories/files that are older than 'x' days except ones named 'dont_delete' from /tmp ?

Code:
#!/bin/bash

find /tmp -mtime +x  ! -name dont_delete -exec rm {} \;
??

Last edited by henkoslaw; 06-09-2012 at 10:34 PM.
 
Old 06-10-2012, 03:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,280
Blog Entries: 54

Rep: Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854Reputation: 2854
Use tmpwatch instead?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to remove files older than 3 days rust8y Linux - General 26 10-04-2012 08:26 AM
[SOLVED] Script: find, compress, remove original files, older than x days? blacklion Linux - General 5 02-27-2012 10:22 AM
bash: delete files older than 7 days in a folder and subfoldes lupomanaro Programming 1 05-07-2008 10:22 AM


All times are GMT -5. The time now is 03:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration