Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should be easy but stuck !!!

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
Currently I run this command in a script to extract data from a log

cat log|tail -150 |grep "Server Window Start"|grep `date +%d-%m-%Y`|grep -v 13-03-2006

I get the following output:
14-03-2006 00:37:36 Server Window Start: 06:00:00 on 14-03-2006
14-03-2006 06:26:06 Server Window Start: 12:00:00 on 14-03-2006

All is well and good apart from I need the first line that is output.However I cant get this as both lines contain (in some format the time starting 06 therefore i cant grep -v 06: in the original command - any ideas ?
 
stick a "|head -1" at the back of the command line you already have:
cat log|tail -150 |grep "Server Window Start"|grep `date +%d-%m-%Y`|grep -v 13-03-2006|head -1

or

cat log|tail -150 |grep "Server Window Start *06:"|grep `date +%d-%m-%Y`|grep -v 13-03-2006


HTH,

p5wizard
 
er ive just done grep -v 12:00:00 and it works.

Blonde moment I think....
 
P5Wizard thanks very much for your help, the way you've done it above is a lot safer than the way ive gone for at least ill catch the first instance each time...
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top