Sponsored Content
Full Discussion: text pattern count statistic
Top Forums Shell Programming and Scripting text pattern count statistic Post 302535953 by bartus11 on Sunday 3rd of July 2011 07:53:44 AM
Old 07-03-2011
If there is only one word per line, then this should work:
Code:
awk '{a[$0]++}END{for (i in a){print i" = "a[i]}}' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to count pattern in column

Hi, I have another problem here on Bash. Assume I have an output file containing two columns which the second one contains :- abc`dgdf`sdfdg` dfgfg```ssd` I would like to count the "`" characters for each line (which is first column). I am wondering what command can I used other than... (12 Replies)
Discussion started by: ahjiefreak
12 Replies

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

3. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

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

5. Shell Programming and Scripting

Filename pattern count

Hi I have the following files in a directory - ds_pl_W_Test ds_pl_list_Test ds_pl_list_Test ds_pl_listl_Test ds_pl_file_Test ds_pl_xx_Test I would like to count the number files in the directory that contain the word "list" I tried the following but it returns zero - ... (3 Replies)
Discussion started by: Prega
3 Replies

6. UNIX for Dummies Questions & Answers

Count pattern occurences

hi, I have a text..and i need to find a pattern in the text and count to the no of times the pattern occured. i have used grep command ..but the problem is , it shows the occurrences of the pattern but doesn't count no of times the pattern occuries. (5 Replies)
Discussion started by: nvnni
5 Replies

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

8. Shell Programming and Scripting

Count Pattern

I need to count the total no of SIN*Y and SIN*N patterns from the below file , The file does not have a record terminators , data in the file is streamed i.e. one line I want to put this count in xml structure <count> <value>$totalcount</value> </count> Tried the following awk... (13 Replies)
Discussion started by: techedipro
13 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. Shell Programming and Scripting

Pattern count in file

hi , I have a below file which contain as Use descriptive thread titles when posting Urgent. For example, do not post questions with subjects like "Help Me!", "Urgent Urgent Urgent" . or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".... (7 Replies)
Discussion started by: Jewel
7 Replies
Msgcat(3pm)						User Contributed Perl Documentation					       Msgcat(3pm)

NAME
Locale::Msgcat - Perl extension for blah blah blah SYNOPSIS
use Locale::Msgcat; $cat = new Locale::Msgcat; $rc = $cat->catopen(name, oflag); $msg = $cat->catgets(set_number, message_number, string); $rc = $cat->catclose(); DESCRIPTION
The Locale::Msgcat module allows access to the message catalog functions which are available on some systems. A new Locale::Msgcat object must first be created for each catalog which has to be open at a given time. The catopen operation opens the catalog whose name is given as argument. The oflag can be either 0 or NL_CAT_LOCALE (usually 1) which is the recommended value. The catgets message retrieves message_number for the set_number message set, and if not found returns string. The catclose function should be used when access to a catalog is not needed anymore. EXAMPLES
use Locale::Msgcat; $cat = new Locale::Msgcat; unless ($cat->catopen("whois.cat", 1)) { print STDERR "Can't open whois catalog. "; exit(1); } printf "First message, first set : %s ", $cat->catgets(1, 1, "not found"); unless ($cat->catclose()) { print STDERR "Can't close whois catalog. "; exit(1); } The above example would print the first message from the first message set found in the whois catalog, or if not found it would print "not found". AUTHOR
Christophe Wolfhugel, wolf@pasteur.fr SEE ALSO
catopen(3), catclose(3), catgets(3), perl(1). perl v5.14.2 1999-11-15 Msgcat(3pm)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy