Sponsored Content
Top Forums Shell Programming and Scripting Script to count particular type of records Post 302534351 by birei on Monday 27th of June 2011 04:06:10 PM
Old 06-27-2011
Hi,

I can't understand what are you looking for.

1.- From your first condition, my count is 1.
2.- From your second condition, my count is 2.

What does your output mean?

Regards,
Birei
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

2. UNIX for Dummies Questions & Answers

Count records in a zip file

Hello, I searched the forums on the keywords in the title I used above, but I did not find the answer: Is it possible to count records in a .zip file on an AIX machine if i don't have pkunzip installed? From all the research I'm reading in google and the reading of pkunzip in Unix.com,... (3 Replies)
Discussion started by: tekster757
3 Replies

3. Shell Programming and Scripting

count characters in specific records

I have a text file which represents a http flow like this: HTTP/1.1 200 OK Date: Fri, 23 Jan 2009 17:16:24 GMT Server: Apache Last-Modified: Fri, 23 Jan 2009 17:08:03 GMT Accept-Ranges: bytes Cache-Control: max-age=540 Expires: Fri, 23 Jan 2009 17:21:31 GMT Vary: Accept-Encoding ... (1 Reply)
Discussion started by: littleboyblu
1 Replies

4. Shell Programming and Scripting

Awk to Count Records with not null

Hi, I have a pipe seperated file I want to write a code to display count of lines that have 20th field not null. nawk -F"|" '{if ($20!="") print NR,$20}' xyz..txt This displays records with 20th field also null. I would like output as: (4 Replies)
Discussion started by: pinnacle
4 Replies

5. Shell Programming and Scripting

count and compare no of records in bash shell script.

consider this as a csv file. H,0002,0002,20100218,17.25,P,barani D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 T,5 N i want to read the csv file and count the number of rows that start with D and... (11 Replies)
Discussion started by: barani75
11 Replies

6. Shell Programming and Scripting

how to count how many subdirectory containing more than a certain number of specific file type

hi I want to write a script which count the number of subdirectories in the current root directory that contain more than a specified number of files of a specific type. Is there an easy way to do this? Thanks Robert (2 Replies)
Discussion started by: piynik
2 Replies

7. Shell Programming and Scripting

How to count dup records in file?

Hi Gurus, I need to count the duplicate records in file file abc abc def ghi ghi jkl I want to get below result: abc ,2 abc, 2 def ,1 ghi ,2 ghi, 2 jkl ,1 or abc ,2 def ,1 (3 Replies)
Discussion started by: ken6503
3 Replies

8. Shell Programming and Scripting

UNIX Script required for count the records in table

Hi Friends, I looking for the script for the count of the records in table. and then it's containg the zero records then should get abort. and should notify us through mail. Can you please help me out in this area i am lacking. (5 Replies)
Discussion started by: victory
5 Replies

9. Shell Programming and Scripting

Count records in a block

Hi, We have a file that has a structure like this: H10 1 2 3 D10 1 D20 1 2 3 D20 3 4 5 D20 4 5 6 D10 2 D20 1 2 3 D20 3 4 5 D20 4 5 6 S10 10 H10 1 2 3 D10 1 D20 1 2 3 D20 3 4 5 D20 4 5 6 D10 2 (2 Replies)
Discussion started by: jerome_rajan
2 Replies

10. UNIX for Dummies Questions & Answers

Count occurrence of string (based on type) in a column using awk

Hello, I have a table that looks like what is shown below: AA BB CC XY PQ RS AA BB CC XY RS I would like the total counts depending on the set they belong to: if search pattern is in {AA, BB, CC} --> count them as Type1 | wc -l (3 Replies)
Discussion started by: Gussifinknottle
3 Replies
MONGOCOLLECTION.GROUP(3)						 1						  MONGOCOLLECTION.GROUP(3)

MongoCollection::group - Performs an operation similar to SQL's GROUP BY command

SYNOPSIS
public array MongoCollection::group (mixed $keys, array $initial, MongoCode $reduce, [array $options = array()]) DESCRIPTION
PARAMETERS
o $keys - Fields to group by. If an array or non-code object is passed, it will be the key used to group results. 1.0.4+: If $keys is an instance of MongoCode, $keys will be treated as a function that returns the key to group by (see the "Passing a $keys function" example below). o $initial - Initial value of the aggregation counter object. o $reduce - A function that takes two arguments (the current document and the aggregation to this point) and does the aggregation. o $options - Optional parameters to the group command. Valid options include: o "condition" Criteria for including a document in the aggregation. o "finalize" Function called once per unique key that takes the final output of the reduce function. o "maxTimeMS"Specifies a cumulative time limit in milliseconds for processing the operation (does not include idle time). If the operation is not completed within the timeout period, a MongoExecutionTimeoutException will be thrown. RETURN VALUES
Returns an array containing the result. CHANGELOG
+--------+----------------------------------------------+ |Version | | | | | | | Description | | | | +--------+----------------------------------------------+ | 1.5.0 | | | | | | | Added "maxTimeMS" option. | | | | |1.2.11 | | | | | | | Emits E_DEPRECATED when $options is scalar. | | | | +--------+----------------------------------------------+ EXAMPLES
Example #1 MongoCollection.group(3) example This groups documents by category and creates a list of names within that category. <?php $collection->insert(array("category" => "fruit", "name" => "apple")); $collection->insert(array("category" => "fruit", "name" => "peach")); $collection->insert(array("category" => "fruit", "name" => "banana")); $collection->insert(array("category" => "veggie", "name" => "corn")); $collection->insert(array("category" => "veggie", "name" => "broccoli")); $keys = array("category" => 1); $initial = array("items" => array()); $reduce = "function (obj, prev) { prev.items.push(obj.name); }"; $g = $collection->group($keys, $initial, $reduce); echo json_encode($g['retval']); ?> The above example will output something similar to: [{"category":"fruit","items":["apple","peach","banana"]},{"category":"veggie","items":["corn","broccoli"]}] Example #2 MongoCollection.group(3) example This example doesn't use any key, so every document will be its own group. It also uses a condition: only documents that match this condition will be processed by the grouping function. <?php $collection->save(array("a" => 2)); $collection->save(array("b" => 5)); $collection->save(array("a" => 1)); // use all fields $keys = array(); // set intial values $initial = array("count" => 0); // JavaScript function to perform $reduce = "function (obj, prev) { prev.count++; }"; // only use documents where the "a" field is greater than 1 $condition = array('condition' => array("a" => array( '$gt' => 1))); $g = $collection->group($keys, $initial, $reduce, $condition); var_dump($g); ?> The above example will output something similar to: array(4) { ["retval"]=> array(1) { [0]=> array(1) { ["count"]=> float(1) } } ["count"]=> float(1) ["keys"]=> int(1) ["ok"]=> float(1) } Example #3 Passing a $keys function If you want to group by something other than a field name, you can pass a function as the first parameter of MongoCollec- tion.group(3) and it will be run against each document. The return value of the function will be used as its grouping value. This example demonstrates grouping by the num field modulo 4. <?php $c->group(new MongoCode('function(doc) { return {mod : doc.num % 4}; }'), array("count" => 0), new MongoCode('function(current, total) { total.count++; }')); ?> PHP Documentation Group MONGOCOLLECTION.GROUP(3)
All times are GMT -4. The time now is 03:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy