Posted By

jhenry on 06/12/07


Tagged

time date command Shell script unix linux files line find


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

noah
alexxx


using find to list old files based on date


 / Published in: Bash
 

URL: http://www.linuxquestions.org/questions/showthread.php?t=7368

  1. find /var/log -mtime -14 -type f -exec ls -al {} \;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jhenry on June 12, 2007

or, to remove all jpg's in the current directory older that two weeks:

$ find . -mtime +14 -type f -name "*.jpg" -exec rm -f {} \;

careful!

Posted By: gsljglkjds on April 8, 2013

First, you need to quote the {} as '{}' in order to prevent your shell from interpreting it. Second, you can just use the -delete flag instead of your rm -f '{}' \; after all.

Posted By: gsljglkjds on April 8, 2013

find /var/log -mtime -14 -type f -delete

You need to login to post a comment.