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 > 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
Adding Multiple Lines to Multiple Files dayinthelife Shell Programming and Scripting 2 06-04-2008 12:50 PM
Simultaneous searching for files (names matching certain criteria) in several directo Hopeful AIX 0 02-13-2008 02:31 PM
deleting files and folders matching criteria H3001 Shell Programming and Scripting 4 06-25-2007 09:20 AM
Please Help. Need Help searching for multiple stings in a file and removing them. mjs3221 UNIX for Advanced & Expert Users 2 08-19-2006 07:28 AM
Searching multiple files with multiple expressions Anahka Shell Programming and Scripting 6 01-07-2004 06:24 PM

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 04-19-2004
Relykk Relykk is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 26
Searching for multiple criteria in log files?

I would like a simple shell script that will allow me to display to screen all unsuccessful su attempts in my sulog file, for the present date.

I have been trying several different combinations of commands, but I can't quite get the syntax correct.

The mess I have right now (don't laugh) is this:

#!/bin/bash
DATE = `date " +%b %d"`
grep $DATE >/dev/null
if ($4 == "-"); then
printf
fi

You can see what I'm trying to accomplish here, but I'm stuck at this point. I tried reading to see if there was a way to use a complex grep or egrep command, but that was a little too complicated for me at this point.

Would someone please help me?

Thank you
  #2 (permalink)  
Old 04-19-2004
home_king home_king is offline
Registered User
  
 

Join Date: Apr 2004
Location: China
Posts: 15
Sorry, I couldn't catch your word.
Maybe explain it in detail please?
  #3 (permalink)  
Old 04-19-2004
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
Try this :
Code:
grep "$(date +'%m/%d') ..:.. -" /var/adm/sulog
  #4 (permalink)  
Old 04-19-2004
Relykk Relykk is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 26
I just would like a simple script that I could use over and over that will search the sulog and print to the screen any failed attempts for whatever the date is at the present time.

I tried playing around with the find command, but I can't figure out how to combine multiple criteria.

I want to find only files without a "+" in the 4th column of the row, such as:

if ($4 == "-")

but having the current date in the second column.

What I was trying to do was something like:

find . -not "+" -a -exec date '{}' \; -print

but obviously doesn't work.
  #5 (permalink)  
Old 04-20-2004
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
find doesn't work on the content of the files.
Have you tried the grep command ?

The syntax is for bash/ksh.
If your shell is sh, modify the command :
grep "`date +'%m/%d'` ..:.. -" /var/adm/sulog

Perhaps, you may have to adapt the pattern depending on the du log format.
On my system, the format of sulog is :
SU 05/16 14:03 + pts/0 sys1aud-root
Closed Thread

Bookmarks

Tags
grep or

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 04:50 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