0

I have a set of multiple log files and i want to search specific strings from those multiple log files between time period say July to October 2015. Please note there are multiple log files for each month like,

test.log.2015-07-01.1
test.log.2015-07-01.2
test.log.2015-07-01.3
test.log.2015-10-31.4
test.log.2015-12-01.5
test.log.2016-02-28.6 

and so on...

Now I am looking for usage log between July-2015 to October-2015 only. Currently, I am using below grep command.

grep -E 'importcoursecustomization|importnoncoursecustomization' test1.log.2015-07-01

How do I use this and search for multiple strings for usage log between July-2015 to October-2015 only?

3
  • Make up your mind. Is it July and October? September and October? Or July to October? Commented Feb 29, 2016 at 11:52
  • July to October Commented Feb 29, 2016 at 12:19
  • Then please edit your question to make it clear. Commented Feb 29, 2016 at 12:32

1 Answer 1

2
grep -E 'importcoursecustomization|importnoncoursecustomization' test1.log.2015-[0,1][7,0]-[0-9][0-9].*

Here First and second [01][09] for month selection on September and October (note that it would also match on 00 and 19 but thankfully they're not valid month numbers) and last two is for day selection.

2
  • Thanks @Bhaumik grep -E 'importcoursecustomization|importnoncoursecustomization' test1.log.2015-[0,1][0,7]-[0-9][0-9] Here, [0,1][0,7] is month ? eg. test.log.2015-[0,7][0,10]-[0-9][0-9] for July to Oct 2015 ? Commented Feb 29, 2016 at 11:29
  • I have to grep strings in logs for July - Oct 2015 Is this correct ? grep -E 'importcoursecustomization|importnoncoursecustomization' test1.log.2015-[0,1][0,7]-[0-9][0-9].* > grep_logs.txt Commented Feb 29, 2016 at 12:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.