to grep log files

Hi, I am using egrep to grep for a particlular date in a log file. However I am getting only first line.

Example in the log below, When I egrep for Nov 12, 2008 I am getting only the first line, but I require all the lines following that. Is there any way by which we can do that.

<Nov 12, 2008 11:03:06 PM EST> <Error> <HTTP> <BEA-101214> <Included resource or file "/motoconfig/gomez_bd_header.html" not found from requested resource "/m
otoconfig/gomez.jsp".>
Size of Env:36
 ModeId:1
 Host:172.20.79.109
 Domain:mphasis
 ModeId:1
 Host:FL08-4492
 Domain:comm.mot.com
 ModeId:1
 Host:mlbp-0090
 Domain:mphasis
 ModeId:1
 Host:mlbp-0101
 Domain:mphasis
 ModeId:1
 Host:172.20.79.74
 Domain:mphasis
 ModeId:1
 Host:MLBP-0097
 Domain:MPHASIS.COM
 ModeId:1
 Host:mjie-0003
 Domain:mphasis
 ModeId:1
 Host:plsu014
conversekidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omarfaridCommented:
can you show sample of logs that have more than one date (same date but different lines)?

Also, can you show the egrep command?
0
conversekidAuthor Commented:
hi
pls find out.txt as attachmet for log file..

egrep "Nov 12, 2008 |11/12" motoconfig1.out is the command I am using

I am getting output like this:

<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <User object is null. Creating anonymous repository.>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Total menu Items: 1>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Menu Id: 33>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Menu Name: Home>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Parent menu name: null>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Parent menu id: -1>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Description: MOTOCONFIG Tool - Home - $$HOME_PAGE$$>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Location: /motoconfig/Home.do>
<Nov 12, 2008 12:53:07 AM EST> <Error> <HTTP> <BEA-101214> <Included resource or file "/motoconfig/gomez_bd_header.html" not found from requested resource "/motoconfig/gomez.jsp".>
<Nov 12, 2008 12:53:07 AM EST> <Error> <HTTP> <BEA-101214> <Included resource or file "/motoconfig/gomez_bd_footer.html" not found from requested resource "/motoconfig/gomez.jsp".>
[11/12 00:53:07.112 AM] jsp_servlet.__gomez _jspService GOMEZ - Time (ms) To Do A JSP Include To The Login Page: 34
[11/12 00:53:07.113 AM] jsp_servlet.__gomez _jspService GOMEZ - Total Test Time (ms) Observed From App. Side: 53
[11/12 00:53:07.113 AM] jsp_servlet.__gomez _jspService GOMEZ -
[11/12 00:53:22.576 AM] jsp_servlet.__gomez _jspService GOMEZ -
[11/12 00:53:22.583 AM] jsp_servlet.__gomez _jspService GOMEZ - Time (ms) To Get 9iRAC Connection: 7
[11/12 0
out.txt
0
ixenator_trialCommented:
In my Linux environment egrep (GNU grep 2.5.3) has a command line option to specify a number of context lines to include.
Context control:
  -B, --before-context=NUM  print NUM lines of leading context
  -A, --after-context=NUM   print NUM lines of trailing context
  -C, --context=NUM         print NUM lines of output context
  -NUM                      same as --context=NUM

Does the following work in your environment?

egrep --after-context=99999999 "Nov 12, 2008 |11/12"  out.txt
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

TintinCommented:
Is there a fixed number of lines after the date you want to extract, or is it variable?
0
TintinCommented:
Assuming a fixed number of lines (and Solaris 10), you can do

/usr/sfw/bin/ggrep -A 20 "Nov 12, 2008 |11/12" motoconfig1.out
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omarfaridCommented:
I tested this on my system and it works:

$  egrep "Nov 12, 2008|11/12" filename  | more

<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <User object is null. Cre
ating anonymous repository.>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Total menu Items: 1>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Menu Id: 33>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Menu Name: Home>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Parent menu name: null>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Parent menu id: -1>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Description: MOTOCONFIG
Tool - Home - $$HOME_PAGE$$>
<Nov 12, 2008 12:53:07 AM EST> <Debug> <iDen> <000000> <Location: /motoconfig/Ho
me.do>
<Nov 12, 2008 12:53:07 AM EST> <Error> <HTTP> <BEA-101214> <Included resource or
 file "/motoconfig/gomez_bd_header.html" not found from requested resource "/mot
oconfig/gomez.jsp".>
<Nov 12, 2008 12:53:07 AM EST> <Error> <HTTP> <BEA-101214> <Included resource or
 file "/motoconfig/gomez_bd_footer.html" not found from requested resource "/mot
oconfig/gomez.jsp".>
[11/12 00:53:07.112 AM] jsp_servlet.__gomez _jspService GOMEZ - Time (ms) To Do
A JSP Include To The Login Page: 34
[11/12 00:53:07.113 AM] jsp_servlet.__gomez _jspService GOMEZ - Total Test Time
(ms) Observed From App. Side: 53
[11/12 00:53:07.113 AM] jsp_servlet.__gomez _jspService GOMEZ -
0
conversekidAuthor Commented:
Hi, omarfarid:
It will give that line..but we require few lines until the date changes again..For example if I am searching for a particular date I want all the lines until the date changes
0
TintinCommented:
Does that mean if you specify Nov 12 as the date, you want all lines listed for that day?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.