Search and filter by TAG


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and filter by TAG
# 15  
Old 01-30-2011
Quote:
Originally Posted by vgersh99
Code:
nawk '$1!="INFO" && $1!="WARN"{A[$6]=$0;c[$6]++} END{for(i in A) {n=index(A[i],ORS);print substr(A[i],1,n) "(" c[i] ")" substr(A[i],n+1)}}' RS="" myFile

hehehehe thank you again vgersh!
Do you like Star Trek? Your nick seem reveals something about you vgersh Smilie
# 16  
Old 01-30-2011
I believe it was 'V...ger'
# 17  
Old 01-30-2011
Quote:
Originally Posted by vgersh99
I believe it was 'V...ger'
Yep! But Enterprise equipage called it: vger (viger)! Smilie
# 18  
Old 01-30-2011
This doesn't do exactly what you want but comes close in a simple way. I just mention it as an f.y.i. as to another approach:
Code:
grep -A 1 -E '^FATAL|ERROR ' inputfile  | tail -6

Gives output like:
Code:
--
FATAL 2011.01.27 20:58:15.242  com.log.SocketConnection doRun
  SOCKET_CLOSE_OK   Closed socket   node SocketQueryListener
--
ERROR 2011.01.27 20:59:40.690  java.lang.String EventDispatcher.logEvent
  PROT_STATE_CHANGE   Protocol handler  : connectConfirmState [NetworkAccessGroup.ClientGroup.Client.1234] changed {4}

Doesn't give the counts like you want. You could get some statistics like this though:
Code:
grep -A 1 -E '^FATAL|ERROR ' inputfile | grep -Eo  '([[:upper:]]+_){1,}[[:upper:]]+'| sort |uniq -c

Outputs:
Quote:
45 PROT_STATE_CHANGE
45 SOCKET_CLOSE_OK
This User Gave Thanks to grepeverything For This Post:
# 19  
Old 01-31-2011
Interesting approach, expecially for the statistic part. I'll use in my script and probably I'll adapt to my needs!

Thanks for feedback!

---------- Post updated 31-01-11 at 04:15 AM ---------- Previous update was 30-01-11 at 02:37 PM ----------

Quote:
Originally Posted by grepeverything
Doesn't give the counts like you want. You could get some statistics like this though:
Code:
grep -A 1 -E '^FATAL|ERROR ' inputfile | grep -Eo  '([[:upper:]]+_){1,}[[:upper:]]+'| sort |uniq -c

Outputs:
Code:
45 PROT_STATE_CHANGE
45 SOCKET_CLOSE_OK


Well, is it possible to have the severity in front of the statistic number and then the rest of the log after the tag?
Something like:

Code:
FATAL [45] SOCKET_CLOSE_OK   Closed socket   node SocketQueryListener
ERROR [45] PROT_STATE_CHANGE   Protocol handler  : connectConfirmState [NetworkAccessGroup.ClientGroup.Client.1234] changed {4}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed search and replace after xml tag

Hi All, I'm new to sed. In following XML file <interface type='direct'> <mac address='52:54:00:86:ce:f6'/> <source dev='eno1' mode='bridge'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> ... (8 Replies)
Discussion started by: varunrapelly
8 Replies

2. Shell Programming and Scripting

Search for a tag and display a message if not found.

Hi All, I am working with a XML file. Below is part for the file. <Emp:Profile> <Emp:Description>Admin</Emp:Description> <Emp:Id>12347</Emp:Id> </Emp:Profile> <Emp:Profile> ... (7 Replies)
Discussion started by: Girish19
7 Replies

3. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

4. Shell Programming and Scripting

Search for a html tag and print the entire tag

I want to print from <fruits> to </fruits> tag which have <fruit> as mango. Also i want both <fruits> and </fruits> in output. Please help eg. <fruits> <fruit id="111">mango<fruit> . another 20 lines . </fruits> (3 Replies)
Discussion started by: Ashik409
3 Replies

5. Shell Programming and Scripting

Need an efficient way to search for a tag in an xml file having millions of rows

Hi, I have an XML file with around 1 billion rows in it and i am trying to find the number of times a particular tag occurs in it. The solution i am using works but takes a lot of time (~1 hr) .Please help me with an efficient way to do this. Lets say the input file is <Root> ... (13 Replies)
Discussion started by: Sheel
13 Replies

6. Shell Programming and Scripting

Multiple Tag Search and Printing

Scenario: The following text belongs to a .doc file File: check1.asmFunction: MonksTag: NoTag: 001Tag: YesTag: 002File: check2.asmFunction: Perl MonksTag: YesTag: 003Tag: NoTag: 004File: check3.asmFunction: ExpertsTag: NoTag: 005Tag: NoTag: 006Function: Perl ExpertsTag: NoTag: 007Tag: YesTag: 008... (1 Reply)
Discussion started by: rajkrishna89
1 Replies

7. Shell Programming and Scripting

search pattern and mark/tag

Hi All, I have to search for patterns from a pattern file in a file and mark the matching lines. Input File: Student1 60 30 Student2 71 91 Student3 88 98 Pattern file: Student1 Fail Student2 Pass Student2 Pass Desired output: Student1 60 30 Fail Student2 71 91 Pass (5 Replies)
Discussion started by: saint2006
5 Replies

8. UNIX for Dummies Questions & Answers

Search and filter between two files

Hello, I have two files in this form that consist of three columns, a name (L*contig*), the length (length=**) and the sequence LT_file.txt LTcontig1 length=13 acccatgctttta LTcontig5 length=8 ggattacc LTcontig8 length=20 ccattgaccgtacctgatcg LTcontig23 length=5 accta and... (5 Replies)
Discussion started by: FelipeAd
5 Replies

9. Shell Programming and Scripting

Search for particular tag and arrange as coordinates

Hi I have a file whose sample contents are shown here, 1.2.3.4->2.4.2.4 a(10) b(20) c(30) 1.2.3.4->2.9.2.4 a(10) c(20) 2.3.4.3->3.6.3.2 b(40) d(50) c(20) 2.3.4.3->3.9.0.2 a(40) e(50) c(20) 1.2.3.4->3.4.2.4 a(10) c(30) 6.2.3.4->2.4.2.5 c(10) . . . . Here I need to search... (5 Replies)
Discussion started by: AKD
5 Replies

10. UNIX for Dummies Questions & Answers

ldap search filter

Hi, I am trying to do an ldapsearch with a filter that checks the uid and the userpassword: $filter= "(&(uid=$user) (userpassword=$password)"; $objs = $ldap->search( base => $basedn, filter => "($filter)"); i based it on this example i found on CPAN: $mesg = $ldap->search( ... (2 Replies)
Discussion started by: tine
2 Replies
Login or Register to Ask a Question