05-10-2008
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
49.95
49.95
49.95
49.95
49.95
49.95
49.95
49.95
49.95
55.96
55.96
49.99
49.99
49.99
49.99
49.99
49.99
49.99
49.99
49.99
The above would produce something like this:
17x49.95, 2x55.96, 9x49.99
2nd example data file
27.96
27.96
27.96
27.96
27.96
27.96
27.96
13.95
2.95
2.95
142.99
142.99
142.99
142.99
142.99
142.99
142.99
produces
7x27.96, 1x13.95, 2x2.95, 7x142.99
I'm trying to find a way to do this with nawk.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
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:
lu S1234L_149_m1_vg.6, part-att 1, vdp-att 1 p-reserver IID 0xdb
registrations:
key 4156 4353 0000 0000
... (3 Replies)
Discussion started by: slipstream
3 Replies
3. Shell Programming and Scripting
Gurus,
Need little guidance.
I have A.txt and B.txt file. B.txt file contains Unique strings.
Sample content of B.txt file for which i cut the fourth column uniquely and output directed to B.txt file
And A.txt file contains the above string as a fourth column which is last column.
So A.txt... (7 Replies)
Discussion started by: Shirisha
7 Replies
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported
Input file is a free flowing file without any format
example of output
ERR-00001=5
....
ERR-01010=10
.....
ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies
6. UNIX for Advanced & Expert Users
1000CUS E Y4NYRETAIL
10010004HELIOPOLIS
110000500022360591000056XX EG
1101DEBY XXAD ZSSKY TSSROS
1102HANYNNYY@HOTMAIL.COM
210030/05/201301/06/2013AED
3100 OPE
3100 CLO
3100 The
1000CUS E Y NYCORPORATE
10010004HELIOPOLIS
110000500025270504550203XX EG
1101XXXQ FOR CTING AND... (1 Reply)
Discussion started by: john2022
1 Replies
7. UNIX for Dummies Questions & Answers
How to find count total number of pattern in a file …
File contains : a.txt
-------------
aaa bbb nnn
ccc aaa bbb
aaa ddd aaa
aaa aaa aaa
grep -c aaa a.txt
Op: 4 ( But my requirement is should count the total no of patterns as 7 ) (4 Replies)
Discussion started by: Jitten
4 Replies
8. Shell Programming and Scripting
I have a directory of files, each with a variable (though small) number of lines. I would like to go through each line in each file, and print the:
-file name
-line number
-number of matches to the pattern /comp/ for each line.
Two example files:
cat... (4 Replies)
Discussion started by: pathunkathunk
4 Replies
9. Shell Programming and Scripting
Guys -
Need your ideas on a section of code to finish something up. To make a long story short, I'm parsing a print output file that goes to pre-printed forms. I'm intercepting it, parsing it, formatting it, cutting it up into individual pages, grabbing the text I want in zones, building an... (3 Replies)
Discussion started by: ampsys
3 Replies
10. UNIX for Beginners Questions & Answers
Guys
I am trying grep to read from pattern file and count occurances of each word.
input is
firstplace
secondplace
secondpot
patternfile is
place
first
second
i want the following.
1-count number of times keywords in patternfile occurs in begining of each line in input file.
so... (12 Replies)
Discussion started by: ahfze
12 Replies
LEARN ABOUT ULTRIX
xgeticonsizes
XSetIconSizes(3X11) XSetIconSizes(3X11)
Name
XSetIconSizes, XGetIconSizes - set or get icon size hints
Syntax
XSetIconSizes(display, w, size_list, count)
Display *display;
Window w;
XIconSize *size_list;
int count;
Status XGetIconSizes(display, w, size_list_return, count_return)
Display *display;
Window w;
XIconSize **size_list_return;
int *count_return;
Arguments
display Specifies the connection to the X server.
count Specifies the number of items in the size list.
count_return
Returns the number of items in the size list.
size_list Specifies a pointer to the size list.
size_list_return
Returns a pointer to the size list.
w Specifies the window.
Description
The function is used only by window managers to set the supported icon sizes.
can generate and errors.
The function returns zero if a window manager has not set icon sizes or nonzero otherwise. should be called by an application that wants
to find out what icon sizes would be most appreciated by the window manager under which the application is running. The application should
then use to supply the window manager with an icon pixmap or window in one of the supported sizes. To free the data allocated in
size_list_return, use
can generate a error.
Property
WM_ICON_SIZE
Diagnostics
The server failed to allocate the requested resource or server memory.
A value for a Window argument does not name a defined Window.
See Also
XSetClassHint(3X11), XSetCommand(3X11), XSetIconName(3X11), XSetNormalHints(3X11), XSetSizeHints(3X11), XSetStandardProperties(3X11), XSet-
TransientForHint(3X11), XSetWMHints(3X11), XSetZoomHints(3X11), XStoreName(3X11)
Guide to the Xlib Library
XSetIconSizes(3X11)