Sponsored Content
Full Discussion: Parse the log file
Top Forums Shell Programming and Scripting Parse the log file Post 302465802 by ctsgnb on Sunday 24th of October 2010 12:02:43 PM
Old 10-24-2010
I am sure there are some more elegant way to do it but ... here is a way

Code:
[ctsgnb@shell ~]$ cat logfile
./abc.sh started at Sun Oct 24 06:42:04 PDT 2010

Message:
=======
Summary Report of NAME count
-----------------------------------------------------------------
Below is the output of the SQL query :-

NAME                                         COUNT
-------------------------------------------------- ----------
DATA                                             1
SEO                                                    1
DIGG                                                        1
FLAG                                        1
TEMP                                                    1
UNIT                                            1
ALL                                                    1
COUNT                                            1
LATE                                             1
ANALYTICS                                             1
IMAGES                                                   1
TER                                                     1
BUZZ                                                    1

13 rows selected.
[ctsgnb@shell ~]$ awk '/^NAME/,/selected/ {print$1}' logfile | sort >filter.s
[ctsgnb@shell ~]$ (echo "DATA SEO SEARCH DIGG FLAG TEMP UNIT GOOG ALL COUNT LATE ANALYTICS YAHOO IMAGES TER BUZZ" | tr \  \\n | sort)>list.s
[ctsgnb@shell ~]$ echo "$(comm -23 list.s filter.s | tr '\n' ' ')"
GOOG SEARCH YAHOO
[ctsgnb@shell ~]$



---------- Post updated at 06:02 PM ---------- Previous update was at 05:30 PM ----------




or something like

Code:
LIST="DATA SEO SEARCH DIGG FLAG TEMP UNIT GOOG ALL COUNT LATE ANALYTICS YAHOO IMAGES TER BUZZ"
for i in $LIST
do ( ! grep $i logfile >/dev/null ) && RES="$i $RES"
done ; echo "RES"


Code:
[ctsgnb@shell ~]$ cat logfile
./abc.sh started at Sun Oct 24 06:42:04 PDT 2010

Message:
=======
Summary Report of NAME count
-----------------------------------------------------------------
Below is the output of the SQL query :-

NAME                                         COUNT
-------------------------------------------------- ----------
DATA                                             1
SEO                                                    1
DIGG                                                        1
FLAG                                        1
TEMP                                                    1
UNIT                                            1
ALL                                                    1
COUNT                                            1
LATE                                             1
ANALYTICS                                             1
IMAGES                                                   1
TER                                                     1
BUZZ                                                    1

13 rows selected.
[ctsgnb@shell ~]$ LIST="DATA SEO SEARCH DIGG FLAG TEMP UNIT GOOG ALL COUNT LATE ANALYTICS YAHOO IMAGES TER BUZZ"
[ctsgnb@shell ~]$ RES=
[ctsgnb@shell ~]$ for i in $LIST
> do ( ! grep $i logfile >/dev/null ) && RES="$i $RES"
> done ; echo "$RES"
YAHOO GOOG SEARCH
[ctsgnb@shell ~]$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse out known messages from a log file

I am looking for a script to do the following. I have a large log file that contains hundreds of warnings, a lot of which can be ignored. The tool doesn't allow me to suppress it, so I like to parse it out from the log file and isolate just the new messages/warnings, based on an exception file. ... (12 Replies)
Discussion started by: cdn2008
12 Replies

2. Shell Programming and Scripting

Piping tail to awk to parse a log file

Hello all, I've got what I'm pretty sure is a simple problem, but I just can't seem to work past it. I'm trying to use awk to pretty up a log file, and calculate a percentage. The log file looks like this: # tail strtovrUsage 20090531-18:15:45 RSreq - 24, RSsuc - 24, RSrun - 78, RSerr -... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

3. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

4. Shell Programming and Scripting

parse a log file and remember last line

Hi all: I'm working on a HPUX 11.23 system and I am needing to parse a tomcat-jakarta log file for memory use. Getting the desired data is easy, assuming the log file does not grow. This file grows constantly and I want to check it q 5 min. The next check will pick up from where it left off 5... (4 Replies)
Discussion started by: raggmopp
4 Replies

5. Shell Programming and Scripting

Sed to parse log file

Hi all, thanks for reading the post. I'm trying to parse hundreds of log files in a directory. One log file looks similar to below: Investigator : Jim_Foo Custodian : Jim_Foo-HDD1-FOO-1234 Export Path : N:\FOO-1234\Foo_Foo Compute MD5 : No File List Only: No Extensions Selected:... (4 Replies)
Discussion started by: chipperuga
4 Replies

6. Shell Programming and Scripting

Check/Parse log file's lines using time difference/timestamp

I was looking at this script which outputs the two lines which differs less than one sec. #!/usr/bin/perl -w use strict; use warnings; use Time::Local; use constant SEC_MILIC => 1000; my $file='infile'; ## Open for reading argument file. open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies

7. Shell Programming and Scripting

Parse A Log File

Hello All, Below is the excerpt from my Informatica log file which has 4 blocks of lines (starting with WRITER_1_*_1). Like these my log file will have multiple blocks of same pattern. WRITER_1_*_1> WRT_8161 TARGET BASED COMMIT POINT Thu May 08 09:33:21 2014... (13 Replies)
Discussion started by: Ariean
13 Replies

8. Shell Programming and Scripting

Parse log file to insert into database

I have a log file that's created daily by this command: sar -u 300 288 >> /var/log/usage/$(date "+%Y-%m-%d")_$(hostname)_cpu.log It that contains data like this: Linux 3.16.0-4-amd64 (myhostname) 08/15/2015 _x86_64_ (1 CPU) 11:34:17 PM CPU %user %nice ... (12 Replies)
Discussion started by: unplugme71
12 Replies

9. Shell Programming and Scripting

Shell Script | Parse log file after a given date and time stamp

I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies

10. UNIX for Beginners Questions & Answers

Parse apache log file with three different time formats

Hi, I want to parse below file and Write a function to extract the logs between two given timestamp. Apache (Unix) Log Samples - MonitorWare The challenge here is there are three date and time format. First :- 07/Mar/2004:16:05:49 Second :- Sun Mar 7 16:02:00 2004 Third :- 29-Mar... (6 Replies)
Discussion started by: sahil_shine
6 Replies
CREATE TEXT SEARCH 
TEMPLATE(7) SQL Commands CREATE TEXT SEARCH TEMPLATE(7) NAME
CREATE TEXT SEARCH TEMPLATE - define a new text search template SYNOPSIS
CREATE TEXT SEARCH TEMPLATE name ( [ INIT = init_function , ] LEXIZE = lexize_function ) DESCRIPTION
CREATE TEXT SEARCH TEMPLATE creates a new text search template. Text search templates define the functions that implement text search dic- tionaries. A template is not useful by itself, but must be instantiated as a dictionary to be used. The dictionary typically specifies parameters to be given to the template functions. If a schema name is given then the text search template is created in the specified schema. Otherwise it is created in the current schema. You must be a superuser to use CREATE TEXT SEARCH TEMPLATE. This restriction is made because an erroneous text search template definition could confuse or even crash the server. The reason for separating templates from dictionaries is that a template encapsulates the ``unsafe'' aspects of defining a dictionary. The parameters that can be set when defining a dictionary are safe for unprivileged users to set, and so creating a dictionary need not be a privileged operation. Refer to in the documentation for further information. PARAMETERS
name The name of the text search template to be created. The name can be schema-qualified. init_function The name of the init function for the template. lexize_function The name of the lexize function for the template. The function names can be schema-qualified if necessary. Argument types are not given, since the argument list for each type of function is predetermined. The lexize function is required, but the init function is optional. The arguments can appear in any order, not only the one shown above. COMPATIBILITY
There is no CREATE TEXT SEARCH TEMPLATE statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH TEMPLATE [alter_text_search_template(7)], DROP TEXT SEARCH TEMPLATE [drop_text_search_template(7)] SQL - Language Statements 2010-05-14 CREATE TEXT SEARCH TEMPLATE(7)
All times are GMT -4. The time now is 05:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy