Sponsored Content
Top Forums Shell Programming and Scripting nawk-how count the number of occurances of a pattern, when don't know the pattern Post 302193599 by cyber111 on Saturday 10th of May 2008 01:23:17 AM
Old 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

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

2. Shell Programming and Scripting

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

How to count number of occurances of string in a file?

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

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

5. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

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

Count number of lines between a pattern in a large file

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 …?

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

Count number of pattern matches per line for all files in directory

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

Identify file pattern, take count of pattern, then act

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

Grep pattern file and count occurances

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
create_bmp_for_rect_in_rect(1)				      General Commands Manual				    create_bmp_for_rect_in_rect(1)

NAME
create_bmp_for_rect_in_rect - bitmap generator for rectangular conductor inside rectangular conductor (part of atlc) SYNOPSIS
create_bmp_for_rect_in_rect [options... ] W H a b c d w h Er1 Er2 filename.bmp WARNING
This man page is not a complete set of documentation - the complexity of the atlc project makes man pages not an ideal way to document it, although out of completeness, man pages are produced. The best documentation that was current at the time the version was produced should be found on your hard drive, usually at /usr/local/share/atlc/docs/html-docs/index.html although it might be elsewhere if your system administrator chose to install the package elsewhere. Sometimes, errors are corrected in the documentation and placed at http://atlc.sourceforge.net/ before a new release of atlc is released. Please, if you notice a problem with the documentation - even spelling errors and typos, please let me know. DESCRIPTION
create_bmp_for_rect_in_rect is a pre-processor for atlc, the finite difference program that is used to calculate the properties of a two and three conductor electrical transmission line of arbitrary cross section. The program create_bmp_for_rect_in_rect is used as a fast way of generating bitmaps (there is no need to use a graphics program), for a rectangular conductor inside a rectangular conductor, with two dieletrics, like this: ----------------------------------------------------- ^ | | | | <--------------d-------------------> | | | | | | <----------w-----------> | | | ------------------------ ^ | | | | | | | | | | Metallic conductor | | | H |<----b-->| conductor (can be | c Er1 | | | | off-centre) | | | | | | | | | | | ------------------------------------ ^ | | | |..................................| | | | | |...Dielectric, permittivity=Er2...| | | | |<-a->|.....(can be off centre ).........| h | | | |..................................| | | | | |..................................| | | | ----------------------------------------------------- | <---------------------------W-----------------------> The parameters 'W' and 'H' and the inner dimensions of the outer conductor. The outer dimensions of the inner conductor are 'w' and 'c'. The inner conductor is assumed to rest on a dielectric (Er2) which is 'd' wide and outer conductor an the inner conductor is offset 'b' from the left hand sidewall of the outer conductor. The whole region is surrounded by a dielectric of relative permittivity 'Er1'. The dielectrics 'Er1' and then 'Er1' and 'Er2' will both be 1.0 The bitmap is printed to the file specifiled as the last argument create_bmp_for_rect_in_rect -f filename.bmp W H a b c d w h Er1 Er2 The bitmaps produced by create_bmp_for_rect_in_rect are 24-bit bit colour bitmaps, as are required by atlc. The permittivities of the bitmap, set by 'Er1' and 'Er2', determine the colours in the bitmap. If Er1 or Er2 is 1.0, 1.0006, 2.1, 2.2, 2.33, 2.5, 3.3, 3.335, 3.7, 4.8, 10.2 or 100, then the colour corresponding to that permittivity will be set according to the colours defined in COLOURS below. If Er1 is not one of those permittivities, the region of permittivity Er1 will be set to the colour 0xCAFF00. If Er2 is not one of those values, then the region of the image will be set to the colour 0xAC82AC. The program atlc does not know what these permittivites are, so they atlc, must be told with the comand line option -d, as in example 4 below. OPTIONS
-b bitmapsize is used to set the size of the bitmap, and so the accuracy to which atlc is able to calculate the transmission line's properties. The default value for 'bitmapsize' is normally 4, although this is set at compile time. The value can be set anywhere from 1 to 15, but more than 8 is probably not sensible. -f outfile Set the output filename. By default, the bitmap is sent to stdout, but it *must* be sent to a file, with this option, or as described above. -v Causes create_bmp_for_rect_in_rect to print some data to stderr. Note, nothing extra goes to standard output, as that is expected to be redirected to a bitmap file. COLOURS
The 24-bit bitmaps that atlc expects, have 8 bits assigned to represent the amount of red, 8 for blue and 8 for green. Hence there are 256 levels of red, green and blue, making a total of 256*256*256=16777216 colours. Every one of the possible 16777216 colours can be defined precisely by the stating the exact amount of red, green and blue, as in: red = 255,000,000 or 0xff0000 green = 000,255,000 or 0x00ff00 blue = 000,000,255 or 0x0000ff black = 000,000,000 or 0x000000 white = 255,255,255 or 0xffffff Brown = 255,000,255 or 0xff00ff gray = 142,142,142 or 0x8e8e8e Some colours, such as pink, turquoise, sandy, brown, gray etc may mean slightly different things to different people. This is not so with atlc, as the program expects the colours below to be EXACTLY defined as given. Whether you feel the colour is sandy or yellow is up to you, but if you use it in your bitmap, then it either needs to be a colour recognised by atlc, or you must define it with a command line option (see OPTIONS and example 5 below). red = 255,000,000 or 0xFF0000 is the live conductor. green = 000,255,000 or 0x00FF00 is the grounded conductor. blue = 000,000,000 or 0x0000FF is the negative conductor All bitmaps must have the live (red) and grounded (green) conductor. The blue conductor is not currently supported, but it will be used to indicate a negative conductor, which will be needed if/when the program gets extended to analyse directional couplers. The following dielectrics are recognised by atlc and so are produced by create_bmp_for_rect_cen_in_rect. white 255,255,255 or 0xFFFFFF as Er=1.0 (vacuum) pink 255,202,202 or 0xFFCACA as Er=1.0006 (air) L. blue 130,052,255 or 0x8235EF as Er=2.1 (PTFE) Mid gray 142,242,142 or 0x8E8E8E as Er=2.2 (duroid 5880) mauve 255.000,255 or 0xFF00FF as Er=2.33 (polyethylene) yellow 255,255,000 or 0xFFFF00 as Er=2.5 (polystyrene) sandy 239,203,027 or 0xEFCC1A as Er=3.3 (PVC) brown 188,127,096 or 0xBC7F60 as Er=3.335 (epoxy resin) Turquoise 026,239,179 or 0x1AEFB3 as Er=4.8 (glass PCB) Dark gray 142,142,142 or 0x696969 as Er=6.15 (duroid 6006) L. gray 240,240,240 or 0xDCDCDC as Er=10.2 (duroid 6010) D. orange 213,160,067 or 0xD5A04D as Er=100.0 (mainly for test purposes) EXAMPLES
Here are a few examples of the use of create_bmp_for_rect_in_rect. Again, see the html documentation in atlc-X.Y.Z/docs/html- docs/index.html for more examples. In the first example, there is just an air dielectric, so Er1=Er2=1.0. The inner of 1x1 inches (or mm, miles etc) is placed centrally in an outer with dimensions 3 x 3 inches. The exact place where the dielectric starts (a) and its width (d) are unimportant, but they must still be entered. % create_bmp_for_rect_in_rect 3 3 1 1 1 1 1 1 > ex1.bmp % atlc ex1.bmp In this second example, an inner of 15.0 mm x 0.5 mm is surrounded by an outer with internal dimensions of 61.5 x 20.1 mm. There is a mate- rial with permittivity 2.1 (Er of PTFE) below the inner conductor. The output from create_bmp_for_rect_in_rect is sent to a file ex1.bmp, which is then processed by atlc % create_bmp_for_rect_in_rect 61.5 20.1 5 22 0.5 50 15 5 1.0 2.1 > ex2.bmp % atlc ex2.bmp In example 3, the bitmap is made larger, to increase accuracy, but otherwise this is identical to the second example. % cre- ate_bmp_for_rect_in_rect -b7 61.5 20.1 5 22 0.5 50 15 5 1.0 2.1 > ex3.bmp % atlc ex3.bmp In the fourth example, materials with permittivites 2.78 and 7.89 are used. While there is no change in how to use cre- ate_bmp_for_rect_in_rect, since these permittivities are not known, we must tell atlc what they are. % create_bmp_for_rect_in_rect 61 20 1 4 22 0.5 50 15 5 2.78 7.89 > ex5.bmp % atlc -d CAFF00=2.78 -d AC82AC=7.89 ex5.bmp In the sixth and final example, the -v option is used to print some extra data to stderr from create_bmp_for_rect_in_rect. SEE ALSO
atlc(1) create_bmp_for_circ_in_circ(1) create_bmp_for_circ_in_rect(1) create_bmp_for_microstrip_coupler(1) cre- ate_bmp_for_rect_cen_in_rect(1) create_bmp_for_rect_cen_in_rect_coupler(1) create_bmp_for_rect_in_circ(1) create_bmp_for_stripline_cou- pler(1) create_bmp_for_symmetrical_stripline(1) design_coupler(1) find_optimal_dimensions_for_microstrip_coupler(1) readbin(1) http://atlc.sourceforge.net - Home page http://sourceforge.net/projects/atlc - Download area atlc-X.Y.Z/docs/html-docs/index.html - HTML docs atlc-X.Y.Z/docs/qex-december-1996/atlc.pdf - theory paper atlc-X.Y.Z/examples - examples Dr. David Kirkby atlc-4.5.0 28th Sept 2003 create_bmp_for_rect_in_rect(1)
All times are GMT -4. The time now is 08:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy