The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
replacing new lines in all files of a directory containing old lines rooster005 Shell Programming and Scripting 1 03-25-2008 03:38 PM
How to delete first 5 lines and last five lines in all text files ragavendran31 Shell Programming and Scripting 10 02-21-2008 07:58 AM
Help!! Need script to read files and add values by lines... dhuertas Shell Programming and Scripting 3 09-16-2007 12:14 AM
need help--script to filter specific lines from multiple txt files I-1 Shell Programming and Scripting 7 02-16-2007 08:42 PM
grepping lines out of files mariner UNIX for Advanced & Expert Users 2 09-24-2004 09:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-30-2007
Nysif Steve Nysif Steve is offline
Registered User
  
 

Join Date: Aug 2007
Location: Albany, NY
Posts: 26
Script lines of a Log Files

I am creating a script that will look through a log file and print the previous days entries. However I do not want the complete line of the entry.

A single line of the log file is as follows:

Aug 30 06:35:08 trnwvltfit1 /usr/lib/snmp/snmpdx: [ID 702911 daemon.error] Agent snmpd appeared dead but responded to ping

I am using the date of the line to determine which lines to print. However, I am only trying to print the parts of the line that are NOT highlighted in red. I have no knowledge of how long the line may be. How can this be done? So far I have:


Code:
$cat messages.log | grep "Aug 30" |

Thanks ahead of time.
  #2 (permalink)  
Old 08-30-2007
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,808
One way:

Code:
grep 'Aug 30' messages.log | awk '{
       printf("%s ",$3)
       for(i=5; i<NF; i++) { printf("%s ", $i)}
       print $NF } '

  #3 (permalink)  
Old 08-30-2007
Nysif Steve Nysif Steve is offline
Registered User
  
 

Join Date: Aug 2007
Location: Albany, NY
Posts: 26
I haven't tested this yet but, will this work for multiple lines in the log file? I would like to implement this so it will go through every line with a date of Aug 30?

Last edited by Nysif Steve; 08-30-2007 at 12:01 PM..
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 11:46 AM.


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