Solved

Deleting files bigger than and/or older than

Posted on 2004-04-24
1
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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.
Suggested Courses

622 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