![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| NFS Mount Points | davidra | UNIX for Dummies Questions & Answers | 1 | 11-28-2007 04:49 PM |
| Gnuplot question: how to plot 3D points as colored points in map view? | karman | UNIX and Linux Applications | 0 | 09-24-2007 07:03 AM |
| how to run prog bet to break points | useless79 | High Level Programming | 1 | 09-07-2007 08:42 AM |
| tar using mount points | legato | UNIX for Dummies Questions & Answers | 3 | 03-30-2005 11:54 PM |
| mount points | manderson19 | UNIX for Advanced & Expert Users | 3 | 04-29-2002 03:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I get entries between two points
Hi,
I am trying to write a script to get entries between two points lets say start and end points from a log file, the log file time format is as follows Start - 07/Aug/2008:18:26:43 End - 07/Aug/2008:19:36:43 I tried using the following awk command but it couldnt pick up the entries in between awk /'06\/Aug\/2008:18:26:43/,/06\/Aug\/2008:18:36:43/' request.log Thanks |
|
||||
|
or without sed, but 6 lines instead of one:
#! /usr/bin/ksh # # # # TOT_LENGTH=`wc -l request.log | awk '{print $1}' | tr -d " "` START_LINE=`grep -n "Start - 07/Aug/2008:18:26:43" request.log | cut -f1 -d:` STOP_LINE=`grep -n "End - 07/Aug/2008:19:36:43" request.log | cut -f1 -d:` LAST_PART=`expr $TOT_LENGTH - $START_LINE` DIFF_START_END=`expr $STOP_LINE - $START_LINE` tail -$LAST_PART request.log | head -$DIFF_START_END ### |
|
||||
|
Hi,
Thanks for your replies, actually I tried both the methods but it doesnt seem to pick up the log entries between the start and end times, The above code Quote:
I tried using the following methods also but without any result 1. awk /'06\/Aug\/2008:18:26:43/,/06\/Aug\/2008:18:36:43/' request.log 2. sed -n -e '/06\/Aug\/2008:18:26:43/,/06\/Aug\/2008:18:36:43/' -e '/06\/Aug\/2008:18:36:43/q' request.log 3. awk '/06\/Aug\/2008:18:26:43/&&f{exit}f;/06\/Aug\/2008:18:36:43/{f++}' request.log A sample log entry is as follows 198.232.219.21 - ukla_portal_23@ukla.com [07/Aug/2008:14:51:23 -0400] "GET HTTPS://modulemgr.stage.ukla.com/mys...e_services.gif HTTP/1.1" 200 148 198.232.219.21 - ukla_portal_23@ukla.com [07/Aug/2008:14:55:23 -0400] "GET HTTPS://modulemgr.stage.ukla.com/mys...vice_green.gif HTTP/1.1" 200 3168 198.232.219.21 - ukla_portal_23@ukla.com [07/Aug/2008:15:05:23 -0400] "GET HTTPS://modulemgr.stage.ukla.com/mys.../gray_line.gif HTTP/1.1" 200 371 The above is just a sample and there are close to 10000 lines in a log file in an hour. Please help me in finding the entries between two points (Start - End ) Your help is greatly appreciated ! Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|