Find files modified in the last 5 days, no more than 2 levels deep in the current directory.

find . -type f -depth -3 -mtime -5
Ever wanted to find the most recently modified files, but couldn't remember exactly where they were in a project directory with many subdirectories? The "find" command, using a combination of "-mtime -N" and "-depth -D" can be used to find those files. If your directory structure isn't very deep, just omit the "-depth -D", but if your directory structure is very deep, then you can limit the depth of the traversal using "-depth -D", where "D" is the maximum number of directory levels to descend.
Sample Output
% find . -depth -3 -mtime -5 -type f
./55x85weddingInv_silverdecklewithbow.doc
./Backup of mark-crystal-rehersal-invite.doc
./Backup of mark-crystal-rsvp.doc
./evite.ics
./m100-uit+totals-2007-12-31-2.xls
./mark-crystal-rehersal-invite.doc
./mark-crystal-rsvp.doc
./respCard_std55x85sheet.doc
./tp2Jl.pdf

-2
By: totoro
2009-03-25 19:54:06

What Others Think

"Thanks for sharing the code that helps in finding files modified in the last 5 days and then I think this will be helpful in understanding the code and most of the post we can see a clear description is available and here also they have provided detailed information of it the page here
Dwyane · 7 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: