0

I have the following files:

file1.txt
file2.txt
file3.txt
...

I want to search inside these files using grep but my search must be limited on files its date is today and 3 day befor for example if file1.txt is created in this day(16/09/2017) and file2.txt is created in (14/09/2017) then grep search only in this two files.

I want to do that command in shell script.

I only know how to search in files using one line command such

grep wordToSearch file*
Ause
  • 3
  • 4
  • I suggest to take a look at `man find`. – Cyrus Sep 17 '17 at 10:41
  • @TomFenech i try that command it not give me anything and second answer is result but i want to not define each time a date – Ause Sep 17 '17 at 11:18
  • 1
    I would recommend that you try and understand the answers proposed in the other question and adapt them to your needs. – Tom Fenech Sep 17 '17 at 11:36

1 Answers1

0
find -type f -mtime -3  -exec grep "wordToSearch" \{\} \;
Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45