LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with Find command (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-find-command-726329/)

wave05 05-15-2009 10:49 PM

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

stress_junkie 05-15-2009 11:42 PM

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. :)

wave05 05-15-2009 11:52 PM

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?

stress_junkie 05-15-2009 11:58 PM

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.

wave05 05-16-2009 07:54 AM

There really are about 100 files that I downloaded yesterday & show a creation date of 5-15-09...

wave05 05-16-2009 09:05 AM

Whoa I GOT IT!

thanks!

stress_junkie 05-16-2009 11:23 AM

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


All times are GMT -5. The time now is 10:08 AM.