Sponsored Content
Full Discussion: Search and count patterns
Top Forums Shell Programming and Scripting Search and count patterns Post 302860435 by sreejithalokkan on Sunday 6th of October 2013 05:46:35 AM
Old 10-06-2013
Search and count patterns

Hi,
I have a text file the contents are like this
Quote:
p
i
Z [720]
i
e
Z [740]
n_
i
Z [0]
k
k
a
Z [720]
T
T
a
Z [0]
m
i
Z [0]
N
i
Z [0]
k
i
Z [0]
now i want to search patterns Z [720], Z [0] etc and count the occurrence of such patterns, after Z value can be any random digits, please help me it is urgent...

output like this
Z [0].............>5
Z [33]............>8

Last edited by sreejithalokkan; 10-06-2013 at 06:53 AM.. Reason: to improve the meaning of post
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
FORMAT(1)						      General Commands Manual							 FORMAT(1)

NAME
format - format a PC floppy diskette SYNOPSIS
format [-v] device [media-size [drive-size]] DESCRIPTION
Format allows a user with read-write permission to device to format a floppy. Either one of the special floppy devices must be used, see fd(4), or an automatic device may be used with the size of the floppy specified on the command line. Two sizes must be given when format- ting a low density diskette in a high density drive. For example: format /dev/at1 format /dev/fd1 1200 format /dev/fd1 360 1200 The first two commands format a 1.2M diskette, the last formats a 360k diskette in a 1.2M drive. A 1.44M drive knows when it's dealing with a low density floppy, so all these commands format a 720k diskette: format /dev/fd0 720 format /dev/fd0 720 1440 format /dev/ps0 No sizes may be specified when using a special floppy device, a size must be specified when using an automatic device. OPTIONS
-v Verify the process by reading each track after formatting it. Formatting is normally blind, the controller has no idea whether it succeeds or not. Use -v on a new box of cheap diskettes, or on a diskette that may have gone bad. Verifying will increase format- ting time by 50%. SEE ALSO
mkfs(1), fd(4). DIAGNOSTICS
Numbers will be printed on standard output to show that it is busy. The locations of bad sectors are printed on standard error when veri- fying. The exit code is zero unless there are too many bad spots. AUTHOR
Kees J. Bot (kjb@cs.vu.nl) FORMAT(1)
All times are GMT -4. The time now is 10:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy