Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search for errors 1

Status
Not open for further replies.

wilmington

Technical User
Nov 21, 2002
3
US
I am trying to check large files for errors. I though I would reduce the list by looking only for files modified in the last day.


find . \( -type d ! -name . -prune \) -o \( -type f -name "*log*" -mtime -1 -print \)


now I need to check for errors in the list of files but only want the errors for the current day.

sample log: Fri Fri Nov 29 06:06:03 2002 error:bad thing, you need to do something about it.

This will give me the day the errors happen.
find . \( -type d ! -name . -prune \) -o \( -type f -name "*log*" -mtime -2 -print \) | |xargs awk '/error:/{print $1}'

Need help on how to read only lines matching the current day then print the complete line with the offending error.

cheers



 
awk -vwd=date "+%a" mm=date "+%b" dd=date "+%d" '{
if( $1 == wd && $2 == mm && $3 == dd) print
}' largefile

Do you mean something like this?


Regards Gregor
Gregor.Weertman@mailcity.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top