Sponsored Content
Top Forums Shell Programming and Scripting Add fields in different files only if some fields between them match Post 302527867 by murpholinox on Monday 6th of June 2011 12:07:09 AM
Old 06-06-2011
MySQL

thank you so much!
could u please, explain me this
'NR==FNR
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match two files and divide fields

I have two files that have the date field in common. I request your help with some script that divide each field value from file1 by the correspond field value of the file2 only when the field date is equal in both files. Thanks in advance ! This is a sample of the files file 1 12/16/2010,... (2 Replies)
Discussion started by: csierra
2 Replies

2. UNIX for Dummies Questions & Answers

Match values from 2 files and append certain fields

Hi, I need help on appending certain field in my file1.txt based on matched patterns in file2.txt using awk or sed. The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly. ... (1 Reply)
Discussion started by: redse171
1 Replies

3. Shell Programming and Scripting

how to match fields from different files in PERL

Howdy! I have multiple files with tab-separated data: File1_filtered.txt gnl|Amel_4.0|Group3.29 1 G R 42 42 60 15 ,.AAA.aa,aa.A.. hh00/f//hD/h/hh gnl|Amel_4.0|Group3.29 2 C Y 36 36 60 5 T.,T, LggJh gnl|Amel_4.0|Group3.29 3 A R 27 27 60 9 Gg,,.gg., B6hcc22_c File2_filtered.txt ... (3 Replies)
Discussion started by: sramirez
3 Replies

4. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

5. Shell Programming and Scripting

awk partial string match and add specific fields

Trying to combine strings that are a partial match to another in $1 (usually below it). If a match is found than the $2 value is added to the $2 value of the match and the $3 value is added to the $3 value of the match. I am not sure how to do this and need some expert help. Thank you :). file ... (2 Replies)
Discussion started by: cmccabe
2 Replies

6. Shell Programming and Scripting

awk to print fields that match using conditions and a default value for non-matching in two files

Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies

7. UNIX for Beginners Questions & Answers

Match Fields between two files, print portions of each file together when matched in ([g]awk)'

I've written an awk script to compare two fields in two different files and then print portions of each file on the same line when matched. It works reasonably well, but every now and again, I notice some errors and cannot seem to figure out what the issue may be and am turning to you for help. ... (2 Replies)
Discussion started by: jvoot
2 Replies

8. UNIX for Beginners Questions & Answers

awk match two fields in two files

Hi, I have two TEST files t.xyz and a.xyz which have three columns each. a.xyz have more rows than t.xyz. I will like to output rows at which $1 and $2 of t.xyz match $1 and $2 of a.xyz. Total number of output rows should be equal to that of t.xyz. It works fine, but when I apply it to large... (6 Replies)
Discussion started by: geomarine
6 Replies

9. Shell Programming and Scripting

Matching two fields in two csv files, create new file and append match

I am trying to parse two csv files and make a match in one column then print the entire file to a new file and append an additional column that gives description from the match to the new file. If a match is not made, I would like to add "NA" to the end of the file Command that Ive been using... (6 Replies)
Discussion started by: dis0wned
6 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
MongoDB::Cursor(3pm)					User Contributed Perl Documentation				      MongoDB::Cursor(3pm)

NAME
MongoDB::Cursor - A cursor/iterator for Mongo query results SYNOPSIS
while (my $object = $cursor->next) { ... } my @objects = $cursor->all; Multithreading Cloning instances of this class is disabled in Perl 5.8.7+, so forked threads will have to create their own database queries. SEE ALSO
Core documentation on cursors: <http://dochub.mongodb.org/core/cursors>. STATIC ATTRIBUTES
slave_okay $MongoDB::Cursor::slave_okay = 1; Whether it is okay to run queries on the slave. Defaults to 0. timeout Deprecated, use MongoDB::Connection::query_timeout instead. How many milliseconds to wait for a response from the server. Set to 30000 (30 seconds) by default. -1 waits forever (or until TCP times out, which is usually a long time). This value is overridden by "MongoDB::Connection::query_timeout" and never used. ATTRIBUTES
started_iterating If this cursor has queried the database yet. Methods mofifying the query will complain if they are called after the database is queried. immortal $cursor->immortal(1); Ordinarily, a cursor "dies" on the database server after a certain length of time (approximately 10 minutes), to prevent inactive cursors from hogging resources. This option sets that a cursor should not die until all of its results have been fetched or it goes out of scope in Perl. Boolean value, defaults to 0. "immortal" is not equivalent to setting a client-side timeout. If you are getting client-side timeouts (e.g., "recv timed out"), set "query_timeout" on your connection. # wait forever for a query to return results $connection->query_timeout(-1); See "query_timeout" in MongoDB::Connection. tailable $cursor->tailable(1); If a cursor should be tailable. Tailable cursors can only be used on capped collections and are similar to the "tail -f" command: they never die and keep returning new results as more is added to a collection. They are often used for getting log messages. Boolean value, defaults to 0. partial If a shard is down, mongos will return an error when it tries to query that shard. If this is set, mongos will just skip that shard, instead. Boolean value, defaults to 0. slave_okay $cursor->slave_okay(1); If a query can be done on a slave database server. Boolean value, defaults to 0. METHODS
fields (\%f) $coll->insert({name => "Fred", age => 20}); my $cursor = $coll->query->fields({ name => 1 }); my $obj = $cursor->next; $obj->{name}; "Fred" $obj->{age}; # undef Selects which fields are returned. The default is all fields. _id is always returned. sort ($order) # sort by name, descending my $sort = {"name" => -1}; $cursor = $coll->query->sort($sort); Adds a sort to the query. Argument is either a hash reference or a Tie::IxHash. Returns this cursor for chaining operations. limit ($num) $per_page = 20; $cursor = $coll->query->limit($per_page); Returns a maximum of N results. Returns this cursor for chaining operations. skip ($num) $page_num = 7; $per_page = 100; $cursor = $coll->query->limit($per_page)->skip($page_num * $per_page); Skips the first N results. Returns this cursor for chaining operations. See also core documentation on limit: <http://dochub.mongodb.org/core/limit>. snapshot my $cursor = $coll->query->snapshot; Uses snapshot mode for the query. Snapshot mode assures no duplicates are returned, or objects missed, which were present at both the start and end of the query's execution (if an object is new during the query, or deleted during the query, it may or may not be returned, even with snapshot mode). Note that short query responses (less than 1MB) are always effectively snapshotted. Currently, snapshot mode may not be used with sorting or explicit hints. hint my $cursor = $coll->query->hint({'x' => 1}); Force Mongo to use a specific index for a query. explain my $explanation = $cursor->explain; This will tell you the type of cursor used, the number of records the DB had to examine as part of this query, the number of records returned by the query, and the time in milliseconds the query took to execute. Requires boolean package. "explain" resets the cursor, so calling "next" or "has_next" after an explain will requery the database. See also core documentation on explain: <http://dochub.mongodb.org/core/explain>. count($all?) my $num = $cursor->count; my $num = $cursor->skip(20)->count(1); Returns the number of document this query will return. Optionally takes a boolean parameter, indicating that the cursor's limit and skip fields should be used in calculating the count. reset Resets the cursor. After being reset, pre-query methods can be called on the cursor (sort, limit, etc.) and subsequent calls to next, has_next, or all will re-query the database. has_next while ($cursor->has_next) { ... } Checks if there is another result to fetch. next while (my $object = $cursor->next) { ... } Returns the next object in the cursor. Will automatically fetch more data from the server if necessary. Returns undef if no more data is available. info Returns a hash of information about this cursor. Currently the fields are: "cursor_id" The server-side id for this cursor. A "cursor_id" of 0 means that there are no more batches to be fetched. "num" The number of results returned so far. "at" The index of the result the cursor is currently at. "flag" If the database could not find the cursor or another error occurred, "flag" may be set (depending on the error). See http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPREPLY <http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPREPLY> for a full list of flag values. "start" The index of the result that the current batch of results starts at. all my @objects = $cursor->all; Returns a list of all objects in the result. AUTHOR
Kristina Chodorow <kristina@mongodb.org> perl v5.14.2 2011-09-07 MongoDB::Cursor(3pm)
All times are GMT -4. The time now is 05:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy