Sponsored Content
Top Forums Shell Programming and Scripting Log File - Getting Info about preceding Date of Pattern Found Post 302437639 by radoulov on Thursday 15th of July 2010 04:06:38 PM
Old 07-15-2010
If you want it on a single line, some sed implementations will require something like this:

Code:
sed -n -e '/^[0-9]\{4\}-[0-1][0-9]-/{ h; }' -e '/agaf@fafa/{ x; s/^\([0-9]\{4\}-[0-1][0-9]-[^,]*\).*/\1/p; }' infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

2. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

3. Solaris

Search date pattern in application log file

I am viewing a file in vi editor and would like to search for a date pattern. In the log, the timestamp is enclosed in parentheses ''. I am using the '/' option in vi to search for the pattern. log snippet: 000000f4 ServletWrappe I SRVE0242I: : Initialization successful. 000000f4... (3 Replies)
Discussion started by: Vangogh78
3 Replies

4. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

5. Shell Programming and Scripting

Count of matched pattern occurences by minute and date in a log file

Anyone knows how to use AWK to achieve the following Sun Feb 12 00:41:01-00:41:59 Success:2 Fail:2 Sun Feb 12 00:42:01-00:42:59 Success:1 Fail:2 Sun Feb 12 01:20:01-01:20:59 Success:1 Fail:2 Mon Feb 13 22:41:01-22:41:59 Success:1 Fail:1 log file: Success Success Fail Fail ... (9 Replies)
Discussion started by: timmywong
9 Replies

6. Shell Programming and Scripting

Need help on appending all the lines in a file after a pattern is found

Hi Friends, I am working on a file which has content as follows Wed,Database,ABC_cube,loaded Wed,Logging,out,user,302002654,active,for,0,minutes Wed,Logging,out,user,109000151,active,for,8,minutes Wed,Logging,out,user,302002654,active,for,0,minutes... (8 Replies)
Discussion started by: dev.devil.1983
8 Replies

7. Shell Programming and Scripting

Getting value of a pattern preceding another pattern

I have a file like this ------------------------------- -------------------------------------- I need a way to find the timestamp preceding the ERR-XXXXX Here XXXX deonoes any any numeric string 00000-99999 that is a output like this 2012-11-12 : 11:59-ERR-XXXXX 2012-11-12 : ... (4 Replies)
Discussion started by: swayam123
4 Replies

8. Shell Programming and Scripting

Copy/print all lines between pattern is found in .log files

Hi, I have a folder with multiple (< 33) .log files. And I have to copy the lines between two patterns from all the .log files to a new file. (script file with a loop?) Thanks in advance. 1.log ... .. xx1> begin ... .. .. >>> Total: 2 Alarms .. .. (17 Replies)
Discussion started by: AK47
17 Replies

9. Shell Programming and Scripting

If first pattern is found, look for second pattern. If second pattern not found, delete line

I had a spot of trouble coming up with a title, hopefully you'll understand once you read my problem... :) I have the output of an ldapsearch that looks like this: dn: cn=sam,ou=company,o=com uidNumber: 7174 gidNumber: 49563 homeDirectory: /home/sam loginshell: /bin/bash uid: sam... (2 Replies)
Discussion started by: samgoober
2 Replies

10. Shell Programming and Scripting

Extract whole word preceding a specific character pattern with first occurence of the pattern

Hello. Here is a file contents : declare -Ax NEW_FORCE_IGNORE_ARRAY=(="§" ="§" ="§" ="§" ="§" .................. ="§"Here is a pattern =I want to extract 'NEW_FORCE_IGNORE_ARRAY' which is the whole word before the first occurrence of pattern '=' Is there a better solution than mine :... (3 Replies)
Discussion started by: jcdole
3 Replies
Catalyst(3pm)						User Contributed Perl Documentation					     Catalyst(3pm)

NAME
Log::Log4perl::Catalyst - Log::Log4perl Catalyst Module SYNOPSIS
In your main Catalyst application module: use Log::Log4perl::Catalyst; # Either make Log4perl act like the Catalyst default logger: __PACKAGE__->log(Log::Log4perl::Catalyst->new()); # or use a Log4perl configuration file, utilizing the full # functionality of Log4perl __PACKAGE__->log(Log::Log4perl::Catalyst->new('l4p.conf')); ... and then sprinkly logging statements all over any code executed by Catalyst: $c->log->debug("This is using log4perl!"); DESCRIPTION
This module provides Log4perl functions to Catalyst applications. It was inspired by Catalyst::Log::Log4perl on CPAN, but has been completely rewritten and uses a different approach to unite Catalyst and Log4perl. Log4perl provides loggers, usually associated with the current package, which can then be remote-controlled by a central configuration. This means that if you have a controller function like package MyApp::Controller::User; sub add : Chained('base'): PathPart('add'): Args(0) { my ( $self, $c ) = @_; $c->log->info("Adding a user"); # ... } Level-based control is available via the following methods: $c->log->debug("Reading configuration"); $c->log->info("Adding a user"); $c->log->warn("Can't read configuration ($!)"); $c->log->error("Can't add user ", $user); $c->log->fatal("Database down, aborting request"); But that's no all, Log4perl is much more powerful. The logging statement can be suppressed or activated based on a Log4perl file that looks like # All MyApp loggers opened up for DEBUG and above log4perl.logger.MyApp = DEBUG, Screen # ... or # All loggers block messages below INFO log4perl.logger=INFO, Screen # ... respectively. See the Log4perl manpage on how to perform fine-grained log-level and location filtering, and how to forward messages not only to the screen or to log files, but also to databases, email appenders, and much more. Also, you can vary the layout of each message. For example if you want to know where a particular statement was logged, turn on file names and line numbers: # Log4perl configuration file # ... log4perl.appender.Screen.layout.ConversionPattern = %F{1}-%L: %p %m%n Messages will then look like MyApp.pm-1869: INFO Saving user profile for user "wonko" Or want to log a request's IP address with every log statement? No problem with Log4perl, just call Log::Log4perl::MDC->put( "ip", $c->req->address() ); at the beginning of the request cycle and use # Log4perl configuration file # ... log4perl.appender.Screen.layout.ConversionPattern = [%d]-%X{ip} %F{1}-%L: %p %m%n as a Log4perl layout. Messages will look like [2010/02/22 23:25:55]-123.122.108.10 MyApp.pm-1953: INFO Reading profile for user "wonko" Again, check the Log4perl manual page, there's a plethora of configuration options. METHODS
new($config, [%options]) If called without parameters, new() initializes Log4perl in a way so that messages are logged similiarly to Catalyst's default logging mechanism. If you provide configuration, either the name of a configuration file or a reference to scalar string containing the configuration, it will call Log4perl with these parameters. The second (optional) parameter is a list of key/value pairs: 'autoflush' => 1 # Log without buffering ('abort' not supported) 'watch_delay' => 30 # If set, use L<Log::Log4perl>'s init_and_watch _flush() Flushes the cache. abort($abort) Clears the logging system's internal buffers without logging anything. Using :easy Macros with Catalyst If you're tired of typing $c->log->debug("..."); and would prefer to use Log4perl's convenient :easy mode macros like DEBUG "..."; then just pull those macros in via Log::Log4perl's :easy mode and start cranking: use Log::Log4perl qw(:easy); # ... use macros later on sub base :Chained('/') :PathPart('apples') :CaptureArgs(0) { my ( $self, $c ) = @_; DEBUG "Handling apples"; } Note the difference between Log4perl's initialization in Catalyst, which uses the Catalyst-specific Log::Log4perl::Catalyst module (top of this page), and making use of Log4perl's loggers with the standard Log::Log4perl loggers and macros. While initialization requires Log4perl to perform dark magic to conform to Catalyst's different logging strategy, obtaining Log4perl's logger objects or calling its macros are unchanged. Instead of using Catalyst's way of referencing the "context" object $c to obtain logger references via its log() method, you can just as well use Log4perl's get_logger() or macros to access Log4perl's logger singletons. The result is the same. COPYRIGHT AND LICENSE
Copyright 2002-2010 by Mike Schilli <m@perlmeister.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-07-21 Catalyst(3pm)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy