LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


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

Rep: Reputation: 0
Help with Find command


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)

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

Ron
 
Old 05-15-2009, 11:42 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
First I would leave off the last upslash in the search directory spec.
/home/data/pictures

Second I would put the \ escape character in front of the * wildcard character.

Third, your time spec of -30 may be off by one. I believe that it will show the files modified in the last 29 days. Test it out and see. You may have to use -31 to get the files modified in the last 30 days. For example, my .bashrc was modified 11 days ago.
Code:
# ls -lah .bashrc
-rw-rw---- 1 root root 81 2009-05-04 17:15 .bashrc
#
# find -mtime -12 -name .bashrc
./.bashrc
# find -mtime -11 -name .bashrc
#
Notice that .bashrc is not listed when I specified -11 as the time spec.

AND, I'm not using root to write this. I had a terminal window logged on as root so I used that to do my examples. I'm using a normal user account to do my regular work.

Last edited by stress_junkie; 05-15-2009 at 11:50 PM.
 
Old 05-15-2009, 11:52 PM   #3
wave05
LQ Newbie
 
Registered: May 2009
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the tips - I made the changes, but it only returns files in the pictures directory... I have a bunch of sub-directories under that with files that match my criteria which do not show up.

Any ideas?
 
Old 05-15-2009, 11:58 PM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
If you have files in the subdirectories that match both criteria then they should be listed. Check to be sure that there really are files that match both criteria in the subdirectories by finding at least one file manually.
 
Old 05-16-2009, 07:54 AM   #5
wave05
LQ Newbie
 
Registered: May 2009
Posts: 7

Original Poster
Rep: Reputation: 0
There really are about 100 files that I downloaded yesterday & show a creation date of 5-15-09...
 
Old 05-16-2009, 09:05 AM   #6
wave05
LQ Newbie
 
Registered: May 2009
Posts: 7

Original Poster
Rep: Reputation: 0
Whoa I GOT IT!

thanks!
 
Old 05-16-2009, 11:23 AM   #7
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
I'm glad I could help, and thank you for posting that you got it figured out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 06:30 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 05:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 05:13 AM
can't find my find command! how to replace? dave247 Debian 4 11-19-2008 11:51 AM
find command George2 Linux - General 2 08-30-2007 02:42 AM


All times are GMT -5. The time now is 11:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration