PDA

View Full Version : grep through only most recent files



sarnzzle
December 27th, 2007, 06:20 PM
Hey this is probably a newbie question, but I'd appreciate the help.

I want to grep through only the most recent files. For example, I want to find all files that have a certain string, but only in files from the last 2 days. I'm pretty sure i've used it before, just can't remember it.

Anyone know the command?

Thanks for the help,
the sarnz

Martin Witte
December 27th, 2007, 06:56 PM
something like find . -mtime -2 -exec grep -l '#!/usr/bin/env python' {} \; put the string you're looking for between the quotes

sdrubolo
December 27th, 2007, 06:57 PM
hi, I'm not completely sure but you should use the command find followed by the option -ctime -n. the explanation taken by the man page is :
-ctime n
File’s status was last changed n*24 hours ago. See the
comments
for -atime to understand how rounding affects the
interpretation
of file status change times.

for the minus is before n:

-n for less than n,
Hope this helps