Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Search for Multiple strings in a given date range and print the Group if they exists Post 303040200 by linuxuser999 on Thursday 24th of October 2019 08:55:08 PM
Old 10-24-2019
Search for Multiple strings in a given date range and print the Group if they exists

Hi,

I am Searching for Multiple strings in a given date range and print the Group if they exists. the below is the format:

Code:
[2019/10/16 13:22:47.961][INFO ][ABCDDDDDDD]
-------------------------------------------------------------------------------------------------------------------------
ID: FIRST ID
MESSAGE: Event Message received.
-------------------------------------------------------------------------------------------------------------------------
CONTEXT: {
  "ID" : 1,
  "event" : "something",
  COMMON_TEXT: COMMON
    "valid" : true
}
*************************************************************************************************************************
[2019/10/16 13:23:00.816][INFO ][ABCDDDDDEEEEEEE]
-------------------------------------------------------------------------------------------------------------------------
ID: SECOND ID
MESSAGE: Event Message received.
-------------------------------------------------------------------------------------------------------------------------
CONTEXT: {
  "ID" : 1,
  "event" : "One More thing",
  COMMON_TEXT: COMMON
    "valid" : true
}
*************************************************************************************************************************
[2019/10/16 13:33:00.816][INFO ][ABCDDDDDEEFFFFFFFFFFFFFEEE]
-------------------------------------------------------------------------------------------------------------------------
ID: THIRD ID
MESSAGE: Event Message received.
-------------------------------------------------------------------------------------------------------------------------
CONTEXT: {
  "ID" : 1,
  "event" : "Second thing",
  COMMON_TEXT: COMMON
    "valid" : False
}
*************************************************************************************************************************

SED COMMAND
Code:
sed -n '/2019\/10\/23 12:2[0-2]/{:a;N;/2019\/10\/23 12:3[0-3]/!ba; /FIRST ID/p}'  logfile

- This is working fine, but I wanted to give one more search criteria along with FIRST ID in the group (like something) and if both exists print the group otherwise skip the group.

AWK Command
Code:
awk 'substr($1,2,11)>="2019\/10\/23" && substr($1,2,11)<="2019\/10\/23" && substr($2,1,8)>="12:22:00" && substr($2,1,8)<="12:33:00"' logfile

I am getting only first line with the dates with this group.

I am not a unix expert, can someone please help on this.

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need to print file names in a certain date range using ls

I need to list only file names of a specific date from the command ls -lt. :confused: (2 Replies)
Discussion started by: Shamwari
2 Replies

2. Shell Programming and Scripting

Search files between a date range

Hi people A newbie here, thrown into the deep end. I want to select the group of files with in a range of dates and perform some operation on it. Are there inbuild date libraries i can use? I did read thru the old posts on this topic. Couldnt get much idea :(, basically want to know how I... (7 Replies)
Discussion started by: zcanji
7 Replies

3. Shell Programming and Scripting

Search multiple Strings in a File

Hi I want to search multiple strings in a file . But the search should start with "From" Keyword and end with before "Where" keyword. Please suggest me. Thanks (2 Replies)
Discussion started by: sboss
2 Replies

4. Shell Programming and Scripting

Search, group , print count

hi All, need help. have a file like below A, error in 123 B, log files are present A, error in 23444 B, log files are present A, move to next line C, matching messages -- expected output-- A , count =2 , error in * A , count =1 , move to next line B , count =2 , log files are present... (2 Replies)
Discussion started by: arun1401
2 Replies

5. Shell Programming and Scripting

Search for a specific data in a file based on a date range

Hi, Currently I am working on a script to automate the process of converting the log file from binary into text format. To achieve this, partly I am depending on my application’s utility for this conversion and the rest I am relying on shell commands to search for directory, locate the file and... (5 Replies)
Discussion started by: svajhala
5 Replies

6. Shell Programming and Scripting

Search on date range of file based on user input

Hello I would like to ask for help with a script to search a directory that contains many log files and based on a users input after being prompted, they enter a date range down to the hour which searches the files that contain that range. I dont know how to go about this. I am hoping that the... (5 Replies)
Discussion started by: lostincashe
5 Replies

7. Shell Programming and Scripting

awk strings search + print next column after match

Hi, I have a file filled with search strings which have a blank in between and look like this: S. g. Ehr. o. Jg. v. d. Chijs g. Ehr. Now i would like to search for the strings and it also shall return the next column after the match. awk -v FILE="search_strings.txt" 'BEGIN {... (10 Replies)
Discussion started by: sdf
10 Replies

8. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

9. Shell Programming and Scripting

Search between two search strings and print the value

Based on the forums i have tried with grep command but i am unable to get the required output. search this value /*------ If that is found then search for temp_vul and print and also search until /*------- and print new_vul Input file contains: ... (5 Replies)
Discussion started by: onesuri
5 Replies

10. UNIX for Dummies Questions & Answers

Search file and print everything except multiple search terms

I'm trying to find a way to search a range of similar words in a file. I tried using sed but can't get it right:sed 's/\(ca01\)*//'It only removes "ca01" but leaves the rest of the word. I still want the rest of the information on the lines just not these specific words listed below. Any... (3 Replies)
Discussion started by: seekryts15
3 Replies
Mail::Message::Head::SpamGroup(3pm)			User Contributed Perl Documentation		       Mail::Message::Head::SpamGroup(3pm)

NAME
Mail::Message::Head::SpamGroup - spam fighting related header fields INHERITANCE
Mail::Message::Head::SpamGroup is a Mail::Message::Head::FieldGroup is a Mail::Reporter SYNOPSIS
my $sg = Mail::Message::Head::SpamGroup->new(head => $head, ...); $head->addSpamGroup($sg); my $sg = $head->addSpamGroup( <options> ); $sg->delete; my @sgs = $head->spamGroups; DESCRIPTION
A spam group is a set of header fields which are added by spam detection and spam fighting software. This class knows various details about that software. METHODS
Constructors $obj->clone() See "Constructors" in Mail::Message::Head::FieldGroup $obj->fighter(NAME, [SETTINGS]) Mail::Message::Head::SpamGroup->fighter(NAME, [SETTINGS]) Get the SETTINGS of a certain spam-fighter, optionally after setting them. The knownFighters() method returns the defined names. The names are case-sensitive. -Option --Default fields <required> isspam <required> version undef fields => REGEXP The regular expression which indicates which of the header fields are added by the spam fighter software. isspam => CODE The CODE must return true or false, to indicate whether the spam fighter thinks that the message contains spam. The CODE ref is called with the spamgroup object (under construction) and the header which is inspected. version => CODE Can be called to collect the official name and the version of the software which is used to detect spam. The CODE ref is called with the spamgroup object (under construction) and the header which is inspected. example: adding your own spam-fighter definitions Mail::Message::Head::SpamGroup->fighter( 'MY-OWN', fields => qw/^x-MY-SPAM-DETECTOR-/, isspam => sub { my ($sg, $head) = @_; $head->fields > 100 } ); $obj->from(HEAD|MESSAGE, OPTIONS) Returns a list of "Mail::Message::Head::SpamGroup" objects, based on the specified MESSAGE or message HEAD. -Option--Default types undef types => ARRAY-OF-NAMES Only the specified types will be tried. If the ARRAY is empty, an empty list is returned. Without this option, all sets are returned. $obj->habeasSweFieldsCorrect([MESSAGE|HEAD]) Mail::Message::Head::SpamGroup->habeasSweFieldsCorrect([MESSAGE|HEAD]) Returns a true value if the MESSAGE or HEAD contains "Habeas-SWE" fields which are correct. Without argument, this is used as instance method on an existing Spam-Group. example: checking Habeas-SWE fields if(Mail::Message::Head::SpamGroup->habeasSweFieldsCorrect($message)) { $message->label(spam => 0); } my $sg = $message->head->spamGroups('Habeas-SWE'); if($sg->habeasSweFieldsCorrect) { ... }; use List::Util 'first'; if(first {$_->habeasSweFieldsCorrect} $head->spamGroups) { ... } $obj->implementedTypes() Mail::Message::Head::SpamGroup->implementedTypes() See "Constructors" in Mail::Message::Head::FieldGroup $obj->isSpamGroupFieldName(NAME) Mail::Message::Head::SpamGroup->isSpamGroupFieldName(NAME) $obj->knownFighters() Mail::Message::Head::SpamGroup->knownFighters() Returns an unsorted list of all names representing pre-defined spam-fighter software. You can ask details about them, and register more fighters with the fighter() method. Mail::Message::Head::SpamGroup->new(FIELDS, OPTIONS) Construct an object which maintains one set of fields which were added by spam fighting software. -Option --Defined in --Default head Mail::Message::Head::FieldGroup undef log Mail::Reporter 'WARNINGS' software Mail::Message::Head::FieldGroup undef trace Mail::Reporter 'WARNINGS' type Mail::Message::Head::FieldGroup undef version Mail::Message::Head::FieldGroup undef head => HEAD log => LEVEL software => STRING trace => LEVEL type => STRING version => STRING $obj->spamDetected([BOOLEAN]) Returns (after setting) whether this group of spam headers thinks that this is spam. See Mail::Message::Head::Complete::spamDetected(). example: die if $head->spamDetected; foreach my $sg ($head->spamGroups) { print $sg->type." found spam " if $sg->spamDetected; } The header $obj->add((FIELD, VALUE) | OBJECT) See "The header" in Mail::Message::Head::FieldGroup $obj->addFields([FIELDNAMES]) See "The header" in Mail::Message::Head::FieldGroup $obj->attach(HEAD) See "The header" in Mail::Message::Head::FieldGroup $obj->delete() See "The header" in Mail::Message::Head::FieldGroup $obj->fieldNames() See "The header" in Mail::Message::Head::FieldGroup $obj->fields() See "The header" in Mail::Message::Head::FieldGroup $obj->head() See "The header" in Mail::Message::Head::FieldGroup Access to the header $obj->software() See "Access to the header" in Mail::Message::Head::FieldGroup $obj->type() See "Access to the header" in Mail::Message::Head::FieldGroup $obj->version() See "Access to the header" in Mail::Message::Head::FieldGroup Internals $obj->collectFields([NAME]) See "Internals" in Mail::Message::Head::FieldGroup $obj->detected(TYPE, SOFTWARE, VERSION) See "Internals" in Mail::Message::Head::FieldGroup Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Message::Head::SpamGroup->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->details() See "Error handling" in Mail::Message::Head::FieldGroup $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Message::Head::SpamGroup->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Message::Head::SpamGroup->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->print([FILEHANDLE]) See "Error handling" in Mail::Message::Head::FieldGroup $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DETAILS
Spam fighting fields Detected spam fighting software The Mail::Message::Head::SpamGroup class can be used to detect fields which were produced by different spam fighting software. o SpamAssassin These fields are added by Mail::SpamAssassin, which is the central implementation of the spam-assassin package. The homepage of this GPL'ed project can be found at <http://spamassassin.org>. o Habeas-SWE Habeas tries to fight spam via the standard copyright protection mechanism: Sender Warranted E-mail (SWE). Only when you have a contract with Habeas, you are permitted to add a few copyrighted lines to your e-mail. Spam senders will be refused a contract. Mail clients which see these nine lines are (quite) sure that the message is sincere. See <http://www.habeas.com> for all the details on this commercial product. o MailScanner The MailScanner filter is developed and maintained by transtec Computers. The software is available for free download from <http://www.sng.ecs.soton.ac.uk/mailscanner/>. Commercial support is provided via <http://www.mailscanner.biz>. DIAGNOSTICS
Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Message::Head::SpamGroup(3pm)
All times are GMT -4. The time now is 06:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy