Sponsored Content
Top Forums Shell Programming and Scripting Count the number of occurrences of a pattern between each occurrence of a different pattern Post 302369880 by rdcwayx on Monday 9th of November 2009 10:35:42 PM
Old 11-09-2009
perfect solution.

Code:
 The gsub function returns the number of substitutions made.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

nawk-how count the number of occurances of a pattern, when don't know the pattern

I've written a script to count the total size of SAN storage LUNs, and also display the LUN sizes. From server to server, the LUNs sizes differ. What I want to do is count the occurances as they occur and change. These are the LUN sizes: 49.95 49.95 49.95 49.95 49.95 49.95 49.95 49.95... (2 Replies)
Discussion started by: cyber111
2 Replies

2. Shell Programming and Scripting

How to count the number of occurences of this pattern?

Hi all, I have a pattern like this in a file: 123 4 56 789 234 5 67 789 121 3 56 789 222 4 65 789 321 6 90 100 478 8 40 789 243 7 80 789 How can I count the number of occurences of '789' (4th column) in this set...? Thanks for all your help! K (7 Replies)
Discussion started by: kripssmart
7 Replies

3. UNIX for Dummies Questions & Answers

Search and Count Occurrences of Pattern in a File

I need to search and count the occurrences of a pattern in a file. The catch here is it's a pattern and not a word ( not necessarily delimited by spaces). For eg. if ABCD is the pattern I need to search and count, it can come in all flavors like (ABCD, ABCD), XYZ.ABCD=100, XYZ.ABCD>=500,... (6 Replies)
Discussion started by: tektips
6 Replies

4. UNIX for Dummies Questions & Answers

line number of the i-th occurrence of a pattern

Hi all, is there a simple way to obtain the line number of the i-th occurrence of a pattern? I have OCCURRENCE=`grep -io "${STRING_NAME}" ${1}-${8}${EXT}.out_bis| wc -l` which tells me how many occurency I have. I would like to go through them and determine the line number and assign... (6 Replies)
Discussion started by: f_o_555
6 Replies

5. Shell Programming and Scripting

counting number of pattern occurrences

Hi All, Is it possible to count number of occurrences of a pattern in a single record using awk?? for example: a line like this: abrsjdfhafa I want to count the number of a character occurrences. but still use the default RS, I don't want to set RS to single character. (1 Reply)
Discussion started by: ghoda2_10
1 Replies

6. Shell Programming and Scripting

How to count the number of files starting with a pattern in a Directory

Hi! In our current directory there are around 35000 files. Out of these a few thousands(around 20000) start with, "testfiles9842323879838". I want to count the number of files that have filenames starting with the above pattern. Please help me with the command i could use. Thank... (7 Replies)
Discussion started by: atechcorp
7 Replies

7. UNIX for Advanced & Expert Users

Unix: list out Pattern occurrence (count)

Need to search a pattern occurrence (count) in a specified file. Below is the details $ cat fruits apple apple ball ball apple ball ball ball apple apple apple cat cat cat cat cat apple apple Note: If I'll use the grep command with -c option then it'll count the 1st occurrence in... (6 Replies)
Discussion started by: tp2115
6 Replies

8. Shell Programming and Scripting

Insert new pattern in newline after the nth occurrence of a line pattern - Bash in Ubuntu 12.04

Hi, I am getting crazy after days on looking at it: Bash in Ubuntu 12.04.1 I want to do this: pattern="system /path1/file1 file1" new_pattern=" data /path2/file2 file2" file to edit: data.db - I need to search in the file data.db for the nth occurrence of pattern - pattern must... (14 Replies)
Discussion started by: Phil3759
14 Replies

9. Shell Programming and Scripting

Match from one pattern to second occurrence of second pattern

Given an XML file that contains (NOT "consists of"): </dict> <key>system.</key> <dict> <key>rule</key> <string>default</string> </dict> <key>system.burn</key> ... (9 Replies)
Discussion started by: jnojr
9 Replies

10. Shell Programming and Scripting

Script to Serach pattern and give number of occurrences

Hi, I want a script which search for a pattern "good" in a huge file and provide me number of occurences of such pattern in a file. lets say i have a file test.txt contents as below good is good but good is sometime bad and sometime good you are very good and good is always good ... (7 Replies)
Discussion started by: sv0081493
7 Replies
MBRUNE(3)						   BSD Library Functions Manual 						 MBRUNE(3)

NAME
mbrune, mbrrune, mbmb -- multibyte rune support for C LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <rune.h> char * mbrune(const char *string, rune_t rune); char * mbrrune(const char *string, rune_t rune); char * mbmb(const char *string, char *pattern); DESCRIPTION
The 4.4BSD ``rune'' functions have been deprecated in favour of the ISO C99 extended multibyte and wide character facilities and should not be used in new applications. Consider working with wide characters instead, and using wcschr(3), wcsrchr(3), and wcsstr(3) instead of these functions. These routines provide the corresponding functionality of strchr(), strrchr() and strstr() for multibyte strings. The mbrune() function locates the first occurrence of rune() in the string pointed to by string. The terminating NUL character is considered part of the string. If rune is '', mbrune() locates the terminating ''. The mbrrune() function locates the last occurrence of rune in the string string. If rune is '', mbrune() locates the terminating ''. The mbmb() function locates the first occurrence of the null-terminated string pattern in the null-terminated string string. If pattern is the empty string, mbmb() returns string; if pattern occurs nowhere in string, mbmb() returns NULL; otherwise mbmb() returns a pointer to the first character of the first occurrence of pattern. RETURN VALUES
The function mbrune() returns a pointer to the located character, or NULL if the character does not appear in the string. The mbrrune() function returns a pointer to the character, or NULL if the character does not appear in the string. The mbmb() function returns a pointer to the pattern, or NULL if the pattern does not appear in the string. SEE ALSO
rune(3), setlocale(3), euc(4), utf2(4), utf8(5) HISTORY
The mbrune(), mbrrune(), and mbmb() functions first appeared in Plan 9 from Bell Labs as utfrune(), utfrrune(), and utfutf(). BSD
April 19, 1994 BSD
All times are GMT -4. The time now is 06:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy