I have a huge list of files in an Unix directory (around 10000 files).
I need to be able to search for a certain keyword only within files that are modified between certain date and time, say for e.g 2012-08-20 12:30 to 2012-08-20 12:40
Can someone let me know what would be the fastest way to perform this search?
I tried using find . -exec grep -l "searchword" {} \; and it is taking a lot of time to perform the search as it searches within all the files in the directory.
I am not very much familiar with Unix.. Any help you could provide is greatly appreciated. Thanks!
Is it possible to let me know one single find command, without writing to a dummy file? Similar to the one below;
for i in $(find -name "*file1*" -o -name "*file2*" );do find $i -ls ; cat $i | grep -i searchword ; done
I use this command to search for a keyword within several files where I know the file name. In this case, I do not know the file name, and I need to search all the files created between two specific dates.
i just tried substituting echo for grep and it lists a whole bunch of files. here is the command I used and the results. I am trying to search for the keyword 023758874 in the files. It just lists around 80 files and none of these files have this searched keyword.
They are not the right files, as they none of these files have the keyword I am searching for. I tried to break up your command for testing
$ touch 201209200700 /tmp/dummy1
$ touch 201209200800 /tmp/dummy2
$ find . \( -newer /tmp/dummy1 -a ! -newer /tmp/dummy2 \)
This should list all files modified after 7 am today and before 8 am today, correct?
but the output of the above commands is just one file and that was created at 10:42 am, which doesn't look right to me.
-rw-r----- 1 spprt 6590 Sep 20 10:42 data.dat