Sponsored Content
Full Discussion: Arrays in awk
Top Forums Shell Programming and Scripting Arrays in awk Post 302883562 by MadeInGermany on Wednesday 15th of January 2014 05:11:27 AM
Old 01-15-2014
So true! Updated.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Two or more arrays in Awk

Hi All, I have been working on awk and arrays. I have this small script: cat maillog*|awk -F: '$2=="SMTP-Accept" && $5~/string/ {lastdate=substr($1,1,8); internaluser=$5; v++} END {for (j in v) {print lastdate, v, j}'| sort>> mail.list This gives me the number of mails users are getting. ... (1 Reply)
Discussion started by: nitin
1 Replies

2. Shell Programming and Scripting

arrays in awk???

Been struggling with a problem, I have been trying to do this in awk, but am unable to figure this out, I think arrays have to be used, but unsure how to accomplish this. I have a input file that looks like this: 141;ny;y;g 789;ct;e;e 23;ny;n;u 45;nj;e;u 216;ny;y;u 7;ny;e;e 1456;ny;e;g... (3 Replies)
Discussion started by: craigsky
3 Replies

3. Shell Programming and Scripting

awk arrays

Guys, OK so i have been trying figure this all all day, i guess its a pretty easy way to do it. Right, so i have to column of data which i have gotten from one huge piece of data. What i would like to do is to put both of these into one array using awk. Is this possible?? If so could... (1 Reply)
Discussion started by: imonthejazz
1 Replies

4. Shell Programming and Scripting

Need Help with awk and arrays

now its owkring - thanks fo rthe help all . (7 Replies)
Discussion started by: fusionX
7 Replies

5. Shell Programming and Scripting

Arrays in awk

Hi, I've written the following code to manipulate the first 40 lines of a data file into my desired order: #!/bin/awk -f { if (NR<=(4)){ a=a$0" "} else { if ((NR >= (5)) && (NR <= (13))) { b=b$0" " } else {if ((NR >= (14)) && (NR <= (25))){ c=c$0" "} ... (5 Replies)
Discussion started by: catwoman
5 Replies

6. Shell Programming and Scripting

awk arrays can do this better - but how?

Hi, I have spent the afternoon trawling Google, Unix.com and Unix in a Nutshell for information on how awk arrays work, and I'm not really getting too far. I ahve a batch of code that I am pretty sure can be better managed using awk, but I'm not sure how to use awk arrays to do what I'm... (1 Reply)
Discussion started by: littleIdiot
1 Replies

7. Shell Programming and Scripting

arrays in awk

Hi, I have the following data in a file for example: Name="Fred","Bob","Peterson","Susan","Weseley" Age="24","30","28","23","45" Study="English","Engineering","Physics","Maths","Psychology" Code="0","0","1","1","0" Name="Fred2","Bob2","Peterson2","Susan2","Weseley2"... (14 Replies)
Discussion started by: james2009
14 Replies

8. UNIX for Dummies Questions & Answers

awk arrays

Hi Can someone please explain the logic of awk arrays. I have been doing some reading but I dont understand this: #!/usr/bin/gawk -f { arr++; } end { for(i in arr) { print arr,i } } As I understand arr refs the arrays index, so while $2 is a string that cant... (2 Replies)
Discussion started by: chronics
2 Replies

9. Shell Programming and Scripting

help in awk arrays!

Hi, buddies I am new to shell scripting and trying to solve a problem. I read about arrays in awk that they are quite powerful and are associative in nature. Awk Gurus Please help! I have a file: Id1 pp1 0t4 pp8 xy2 Id43 009y black Id6 red xy2 Id12 new pp1 black I have... (5 Replies)
Discussion started by: geli21
5 Replies

10. Shell Programming and Scripting

Using arrays with awk

I'm a little stuck and would be grateful of some advice! I have three files, two of which contain reference data that I want to add to a line of output in the third file. I can't seem to get awk to print array contents as I would expect. The input files are: # Input file AAA,OAA,0313... (2 Replies)
Discussion started by: maccas17
2 Replies
MONGODBDRIVERBULKWRITE(3)						 1						 MONGODBDRIVERBULKWRITE(3)

The MongoDBDriverBulkWrite class

INTRODUCTION
The MongoDBDriverBulkWrite collects one ore more write operations that should be sent to the server in writees. The MongoDBDriverManager has 3 wrapper methods for single-item writees for simplicity: o MongoDBDriverManager::executeInsert o MongoDBDriverManager::executeDelete o MongoDBDriverManager::executeUpdate along with the main method to execute a write: MongoDBDriverManager::executeBulkWrite When constructing a write, you must define if the write should be executed in order (default), or if it can be reordered by the server. Ordered write write operations are sent to the server, in the order provided, for serial execution. If a write fails, any remaining opera- tions will be aborted. Unordered operations are sent to the server in arbitrary order where they may be executed in parallel. Any errors that occur are reported after all operations have been attempted. CLASS SYNOPSIS
MongoDB0 final MongoDB0ntable Methods o public MongoDBDriverBulkWrite::__construct ([boolean $ordered = true]) o public int MongoDBDriverBulkWrite::count (void ) o public void MongoDBDriverBulkWrite::delete (array|object $filter, [array $deleteOptions]) o public MongoDBDriverObjectID MongoDBDriverBulkWrite::insert (array|object $document) o public void MongoDBDriverBulkWrite::update (array|object $filter, array|object $newObj, [array $updateOptions]) EXAMPLES
Example #1 Mixed write operations sent in groupped writees Mixing write operations (insert/update/delete) will create internal sub-writees and will be sent sequentially to the server. <?php $write = new MongoDBDriverBulkWrite(true); $write->insert($a); $write->update($b, $obj); $write->update($c, $obj); $write->insert($d); $write->insert($e); $write->delete($f); ?> Will result in 4 writes (round-trips) being executed. Example #2 Ordered BulkWrite causing error <?php $write = new MongoDBDriverBulkWrite(false); $write->delete([]); $write->insert(["_id" => 1]); $write->insert(["_id" => 2]); $write->insert(["_id" => 3, "hello" => "world"]); $write->update(["_id" => 3], ['$set' => ["hello" => "earth"]]); $write->insert(["_id" => 4, "hello" => "pluto"]); $write->update(["_id" => 4], ['$set' => ["hello" => "moon"]]); $write->insert(["_id" => 3]); $write->insert(["_id" => 4]); $write->insert(["_id" => 5]); $manager = new MongoDBDriverManager("mongodb://localhost:27017"); $writeConcern = new MongoDBDriverWriteConcern(MongoDBDriverWriteConcern::MAJORITY, 1000); try { $result = $manager->executeBulkWrite("databaseName.collectionName", $write, $writeConcern); } catch(MongoDBDriverDuplicateKeyException $ex) { $result = $ex->getWriteResult(); printf("Inserted %d document(s) ", $result->getInsertedCount()); printf("Updated %d document(s) ", $result->getModifiedCount()); /* If the WriteConcern could not be fullfilled */ if ($writeConcernError = $result->getWriteConcernError()) { printf("%s (%d): %s ", $writeConcernError->getMessage(), $writeConcernError->getCode(), var_export($writeConcernError->getInfo(), true) ); } /* If the write could not happen at all */ foreach ($result->getWriteErrors() as $writeError) { printf("Operation#%d: %s (%d) ", $writeError->getIndex(), $writeError->getMessage(), $writeError->getCode() ); } } catch(MongoDBDriverAuthenticationException $ex) { } catch(MongoDBDriverConnectionException $ex) { } catch(MongoDBDriverRuntimeException $ex) { } ?> The above example will output: Inserted 4 document(s) Updated 2 document(s) Operation#7: E11000 duplicate key error index: databaseName.collectionName.$_id_ dup key: { : 3 } (11000) If the WriteConcern could not be fullfilled, the example above would output something like: Inserted 4 document(s) Updated 2 document(s) waiting for replication timed out (64): array ( 'wtimeout' => true, ) Operation#7: E11000 duplicate key error index: databaseName.collectionName.$_id_ dup key: { : 3 } (11000) Executing the same example, changing the order to false: <?php $write = new MongoDBDriverBulkWrite(false); /* ... */ ?> The above example will output: Inserted 5 document(s) Updated 2 document(s) Operation#7: E11000 duplicate key error index: databaseName.collectionName.$_id_ dup key: { : 3 } (11000) Operation#8: E11000 duplicate key error index: databaseName.collectionName.$_id_ dup key: { : 4 } (11000) SEE ALSO
o MongoDBDriverManager::executeBulkWrite oMongoDBDriverWriteResult oMongoDBDriverWriteConcern oMongoDBDriverWriteConcernError oMongoDBDriverWriteError PHP Documentation Group MONGODBDRIVERBULKWRITE(3)
All times are GMT -4. The time now is 12:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy