Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Deleting files bigger than and/or older than

Posted on 2004-04-24
1
Medium Priority
?
434 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 375 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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). …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

721 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