LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-15-2009, 10:31 PM   #1
wave05
LQ Newbie
 
Registered: May 2009
Posts: 7

Rep: Reputation: 0
Find ommand multiple criteria


Hi,

I want to look for files within a bunch of sub dirs below a point in the directory tree that are both jpg and modified within the last 30 days.

When I use: find /home/data/pictures/ -mtime -30
I get all files modified in the last 30 days (within all sub dirs under pictures)

When I use:find /home/data/pictures/ -name *.jpg
I get all jpg files (within all sub dirs under pictures)

When I use:find /home/data/pictures/ -name *.jpg -mtime -30
I don't get any files from the sub directories (Only files within the pictures directory)

How can I get all files in the pictures sub directories using both criteria?

Ron
wave05 is offline Reply With Quote
 
Old 05-16-2009, 12:17 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
your find command should work. also, try to use quotes
Code:
find . -iname "*.jpg" -mtime -30
alternatively, if you don't mind using Python
Code:
!#/usr/bin/env python
import os
import time
thirtydays = 86400*30
now = time.time()
directory=os.path.join("/home","user","path") #change accordingly
for r,d,f in os.walk(directory):
    for files in f:
        if files[-4:].lower()==".jpg":
            timestamp = os.path.getmtime( os.path.join(r,files) )
            if now-thirtydays < timestamp:
                print os.path.join(r,files)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux find to find files with multiple patterns subu_s Programming 6 12-15-2010 12:15 AM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 04:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 04:13 AM
Installation criteria puniti Linux - Networking 1 07-31-2003 03:43 AM
Search criteria finegan LQ Suggestions & Feedback 3 04-22-2002 04:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration