Solved

Deleting files bigger than and/or older than

Posted on 2004-04-24
1
431 Views
Last Modified: 2013-12-16
hi I can finger out the command to a delete all files in a directory bigger that say 40k except one over 40k called image.jpg
And similarly files in a directory older than 20 days say except the same file

thanks greenbug2000

0
Comment
Question by:greenbug2000
1 Comment
 
LVL 40

Accepted Solution

by:
jlevie earned 125 total points
ID: 10908150
You can identify all files older than 20 days in a directory or its sub dirs except image.jpg with:

find some-dir -type f -not -name image.jpg -ctime +20

and to the delete those add "-exec rm [] \;" to the command, like:

find some-dir -type f -not -name image.jpg -ctime +20 -exec rm {} \;

In a like manner replacing "-ctime +20" with -size 40k should remove all files 40k or more except image.jpg.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Securing Azure Oracle instance of Linux VM 4 74
Run Secure WMI query from CentOS 5 131
parallel rsync issues with Ubuntu 1 39
Advice on ESXi 5.1 Health / Storage 1 40
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question