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
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 12-01-2008 11:37 PM
Date parsing into string, help! martyb555 Shell Programming and Scripting 5 02-17-2008 10:12 PM
need to create a file with its name having system date hamsa Shell Programming and Scripting 11 10-18-2006 05:48 AM
Command DATE in UNIX System ZINGARO UNIX for Dummies Questions & Answers 3 07-20-2006 06:07 PM
file date vs. system date ober5861 UNIX for Dummies Questions & Answers 8 09-11-2001 03:36 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-09-2007
cjones cjones is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 3
parsing a system log file via the 'date' command

Hello,

I'm trying to update some scripts here that parse our system logs daily. They report information just fine... but they just report too much info.

Specifically, if there's been some failed login attempts on several different days (say Monday and Tuesday), when I get the report from Wendsday, I don't want to see Wednesday's info *in addition* to Monday & Tuesday (and so on throughout the week).

This is happening because of this syntax that I've found isn't working:

grep -i fail $LOGDIR/$LOG2 |grep `date |awk '{print $2}' ` | grep `date |awk '{print $3}'

This is giving me information for every day in my logfile... not just on the day the script is running - which is what I prefer.

It seems like if I could make use of this aspect of the date command I'd be ok:

% date '+%C'
Wed May 9 08:23:20 EDT 2007

since the 'May 9' (May, with two spaces and then the 9) is exactly how the syntax of the month/day shows up:

May 9 08:27:10 mysystem sshd2[15562]: [ID 702911 auth.error] auths-pam: PAM subprocess returned packet SSH_PAM_OP_ERROR. (err_num: 9, err_msg: Authentication failed)
May 9 08:27:10 mysystem sshd2[15562]: [ID 702911 auth.notice] Password authentication for user cjones failed (from xxx.xxx.xxx.xxx port 53341).

So... my thinking is that if I could find the right use of the 'date' command then I could use that with a grep to pull out *exactly* what I want out of my logfiles. But it's also possible there's a different way to get the same results.

I'd prefer to do this in a sh/csh script also.

Thanks in advance!

-chris
 

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 02:56 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