Solved

Deleting files bigger than and/or older than

Posted on 2004-04-24
1
428 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now