Count the number of occurrences of a pattern between each occurrence of a different pattern
I need to count the number of occurrences of a pattern, say 'key', between each occurrence of a different pattern, say 'lu'.
Here's a portion of the text I'm trying to parse:
Here's the output I'm hoping to achieve:
With my rudimentary awk skills I thought I might build on answers to similar questions in the forum by creating separate temporary files for each occurrence of 'lu' and counting the occurrences of 'key' with grep. I think I'm fighting Darwin's implementation of awk though, e.g.:
I'm also not sure if this something better suited for building with sed, e.g. something including:
Thanks for any help or examples you can point me to..
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)