How to find files in linux

16 Jan, 2008  |  Posted by Danesh  |  in HowTo, Linux

Need to find files older than certain time frame? This will help, “find [dir] -type f -mtime +[24hours*n] ”

Examples,

Show files older than 7 days

find /tmp/ -type f -mtime +7

Show files older than 7 days and rm them.

find /tmp/ -type f -mtime +7 -exec rm {} \;

or if you have a large number of files

find /tmp/ -type f -mtime +7 | xargs rm
  • Digg
  • del.icio.us
  • BlinkList
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Furl
  • Google
  • Live
  • Facebook
  • Pownce
  • TwitThis
  • E-mail this story to a friend!
Tags: , , , ,

2 Responses so far | Have Your Say!

  1. hongkiat  |  January 16th, 2008 at 1:34 pm #

    Nice little tricks, saving them to my routine use list :-)

    hongkiat - Gravatar
  2. josh  |  June 11th, 2008 at 3:17 pm #

    .

    Search for files on Linux quickly using the command line:

    article:
    http://www.codetechnical.com/linux/search-for-a-file-in-linux.html

    .

    josh - Gravatar

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>