The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
change record detail...in file happyv Shell Programming and Scripting 5 03-12-2007 01:06 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
how to use the grep to find detail in a file etravels SUN Solaris 1 03-10-2004 02:03 PM
what does metaroot in detail? hugo_perez UNIX for Advanced & Expert Users 3 08-05-2003 05:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-22-2002
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Getting detail out of a log file...

I'd like to peruse a log file and from it generate another file from the first instance of "Jul 11" to the first instance of "Jul 18" within the log file.
  #2 (permalink)  
Old 08-22-2002
auswipe's Avatar
auswipe auswipe is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Wide Awake Wylie, Texas
Posts: 535
Re: Getting detail out of a log file...

Quote:
Originally posted by Cameron
I'd like to peruse a log file and from it generate another file from the first instance of "Jul 11" to the first instance of "Jul 18" within the log file.
Are you wanting Jul 11 and Jul 18 to be the lower and upper limit and display everything between?

For first instance finding, I found this thread (that I participated in) in the search:

finding first instance
  #3 (permalink)  
Old 08-22-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
You could also probably strip that out with a fairly simple shell script - can you post a rough example of the format of the log file?
  #4 (permalink)  
Old 08-22-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
This is the sort of thing I would be likely to want to...so I had a play and see if this will work for you:

Code:
#!/bin/ksh
#
start_row=`awk -F"," '{ if ( $1 == "one" && start_def != "True" )
        { start_def="True"; start_row = NR -1 ; print start_row}} ' biglog`
#
end_row=`awk -F"," '{ if ( $1 == "two" && end_def != "True" )
        { end_def = "True" ; end_row = NR +1 ; print end_row}} ' biglog`
#
sed -e "1,$start_row d" -e "$end_row,$ d" biglog > new_file
It's probably not as pretty as it could be....and it is assuming that the value will be in the first field..... but you can tweak it of course.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0