Search and count patterns

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and count patterns
# 8  
Old 10-06-2013
Thank you Scrutinizer... I just seen sorry
# 9  
Old 10-06-2013
Originally Posted by Akshay Hegde
Thank you Scrutinizer... I just seen sorry
Don't be sorry, thanks for pointing it out, it is a valid point!
# 10  
Old 10-06-2013
Another way:
$ egrep -o '^Z \[[0-9]+\]' File | sort | uniq -c
      5 Z [0]
      2 Z [720]
      1 Z [740]

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for patterns on different lines

im using the following code to search a log for entries on two different lines: awk 'BEGIN{count=0} /'"${firstpattern}"'/,/'"${secondpattern}"'/ { print; if ($0 ~ /'"${thirdpattern}"'/){count++}; } END { print count }' data.txt firstpattern="start error log" secondpattern="i am logging the... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

awk to print before and after lines then count of patterns

What i'm trying to do here is show X amount of lines before and after the string "serialNumber" is found. BEFORE=3 AFTER=2 gawk '{a=$0} {count=0} /serialNumber/ && /./ {for(i=NR-'"${BEFORE}"';i<=NR;i++){count++ ;print a}for(i=1;i<'"${AFTER}"';i++){getline; print ; count ++; print... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Shell Programming and Scripting

Awk to Count Multiple patterns in a huge file

Hi, I have a file that is 430K lines long. It has records like below |site1|MAP |site2|MAP |site1|MODAL |site2|MAP |site2|MODAL |site2|LINK |site1|LINK My task is to count the number of time MAP, MODAL, LINK occurs for a single site and write new records like below to a new file ... (5 Replies)
Discussion started by: reach.sree@gmai
5 Replies

4. Shell Programming and Scripting

count the number of occurring patterns in a file.

Hi, I have a file with a '|' pipe delimeter. I want to find number of counts for a particular pattern in particular field. Is it possible to do it in a single command? 1) want to find total number of "0" in field 4. 2) want to find total number of different records in field 4 ( similar to... (5 Replies)
Discussion started by: rudoraj
5 Replies

5. Shell Programming and Scripting

Search by patterns case

42 network read failed sv1 sv23 sv4 sv11 sv23 sv5 sv 7 48 client hostname could not be found sv21 sv78 sv19 sv22 sv111 sv203 sv5 sv 33 49 client did not start sv1 sv21 54 timed out connecting to client sv2 sv4 sv12 above is my file , I'd like to use a script to list all name... (5 Replies)
Discussion started by: Sara_84
5 Replies

6. Shell Programming and Scripting

Search for the two patterns and print everything in between

Hi all, I have a file having data: @HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTAATA NTTGGGTTTTCT @HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTA... NTTGGGTTTTCT @HWUSI-EAS1727:19:6:1:3674:984:0:1#.....CT NTTGGGTTTTCT I want to print everything starting from # till line ends. can you please help me how... (5 Replies)
Discussion started by: pirates.genome
5 Replies

7. UNIX for Advanced & Expert Users

Count number of unique patterns from a log file

Hello Everyone I need your help in fixing this issue., I have a log file which has data of users logging in to an application. I want to search for a particular pattern in the log ISSessionValidated=N If this key word is found , the above 8 lines will contain the name of the user who's... (12 Replies)
Discussion started by: xtechkid
12 Replies

8. Shell Programming and Scripting

search multiple patterns

I have two lists in a file that look like a b b a e f c d f e d c I would like a final list a b c d e f I've tried multiple grep and awk but can't get it to work (8 Replies)
Discussion started by: godzilla07
8 Replies

9. Shell Programming and Scripting

Count lines between two patterns inside a file

Hi, Im doing a script to find the number of lines included inside a file newly. These lines are in between #ifdef FLAG1 and #else or #endif or #else and #endif. I tried like this, awk '/#ifdef Flag1/,/#e/{print}' aa.c | wc -l awk '/#ifndef Flag1/,/#endif/{print}' aa.c | awk... (6 Replies)
Discussion started by: priyadarshini
6 Replies

10. Shell Programming and Scripting

search patterns

hello, i have an input file of about 50,00,000 lines. few of its lines are as follows: <CR:0023498789,TPO-14987084;BO=IC&SUB=ALLP <CF:0023498789,CB=YES;BIL&NC=NO <CF:0023498789,CW=NO;NS=NO <GC:0023498789,CG=YES;TPO&NC=YES <CR:0024659841,TPO-14484621;BO=NO&BA=OC&SUB=ALLH... (1 Reply)
Discussion started by: rochitsharma
1 Replies
Login or Register to Ask a Question