Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk match two fields in two files Post 303018647 by vgersh99 on Tuesday 12th of June 2018 01:41:49 PM
Old 06-12-2018
a slightly simplified variation:
Code:
awk '{idx=$1 SUBSEP $2} FNR==NR{a[idx];next} idx in a'  t.xyz a.xyz > out.xyz

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK break string into fields + pattern match

I am trying to break a string into separate fields and print the field that matches a pattern. I am using awk at the moment and have gotten this far: awk '{for(i=1;i<=NF;++i)print "\t" $i}' longstring This breaks the string into fields and prints each field on a separate line. I want to add... (2 Replies)
Discussion started by: Moxy
2 Replies

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

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

Add fields in different files only if some fields between them match

Hi everybody (first time posting here) I have a file1 that looks like > 1,101,0.1,0.1 1,26,0.1,0.1 1,3,0.1,0.1 1,97,0.5,0.5 1,98,8.1,0.218919 1,99,6.2,0.248 2,101,0.1,0.1 2,24,3.1,0.147619 2,25,23.5,0.559524 2,26,34,0.723404with 762 lines.. I have another 'similar' file2 > ... (10 Replies)
Discussion started by: murpholinox
10 Replies

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

6. Shell Programming and Scripting

awk to calculate fields only if match is found

Trying to combine the matching $5 values between file1 and file2. If a match is found then the last $6 value in the match and the sum of $7 are outputted to a new file. The awk below I hope is a good start. Thank you :). file1 chr12 9221325 9221448 chr12:9221325-9221448 A2M 1... (5 Replies)
Discussion started by: cmccabe
5 Replies

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

8. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

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

10. Shell Programming and Scripting

awk to update file based on match in 3 fields

Trying to use awk to store the value of $5 in file1 in array x. That array x is then used to search $4 of file1 to find aa match (I use x to skip the header in file1). Since $4 can have multiple strings in it seperated by a , (comma), I split them and iterate througn each split looking for a match.... (2 Replies)
Discussion started by: cmccabe
2 Replies
SoMFVec3b(3)							       Coin							      SoMFVec3b(3)

NAME
SoMFVec3b - The SoMFVec3b class is a container for SbVec3b vectors. This field is used where nodes, engines or other field containers needs to store an array of vectors with three elements. SYNOPSIS
#include <Inventor/fields/SoMFVec3b.h> Inherits SoMField. Public Member Functions virtual SoType getTypeId (void) const virtual void copyFrom (const SoField &field) const SoMFVec3b & operator= (const SoMFVec3b &field) virtual SbBool isSame (const SoField &field) const SbVec3b operator[] (const int idx) const const SbVec3b * getValues (const int start) const int find (SbVec3b value, SbBool addifnotfound=FALSE) void setValues (const int start, const int num, const SbVec3b *newvals) void set1Value (const int idx, SbVec3b value) void setValue (SbVec3b value) SbVec3b operator= (SbVec3b val) SbBool operator== (const SoMFVec3b &field) const SbBool operator!= (const SoMFVec3b &field) const SbVec3b * startEditing (void) void finishEditing (void) void setValuesPointer (const int num, const SbVec3b *userdata) void setValuesPointer (const int num, SbVec3b *userdata) void setValuesPointer (const int num, const int8_t *userdata) void setValuesPointer (const int num, int8_t *userdata) void setValues (int start, int num, const int8_t xyz[][3]) void set1Value (int idx, int8_t x, int8_t y, int8_t z) void set1Value (int idx, const int8_t xyz[3]) void setValue (int8_t x, int8_t y, int8_t z) void setValue (const int8_t xyz[3]) Static Public Member Functions static void * createInstance (void) static SoType getClassTypeId (void) static void initClass (void) Protected Member Functions virtual void deleteAllValues (void) virtual void copyValue (int to, int from) virtual int fieldSizeof (void) const virtual void * valuesPtr (void) virtual void setValuesPtr (void *ptr) virtual void allocValues (int num) Protected Attributes SbVec3b * values Detailed Description The SoMFVec3b class is a container for SbVec3b vectors. This field is used where nodes, engines or other field containers needs to store an array of vectors with three elements. This field supports application data sharing through a setValuesPointer() method. See SoMField documentation for information on how to use this function. See also: SbVec3b, SoSFVec3b Be aware that this class is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API. Since: Coin 2.5 Member Function Documentation SoType SoMFVec3b::getClassTypeId (void) [static] Returns a unique type identifier for this field class. See also: getTypeId(), SoType Reimplemented from SoMField. SoType SoMFVec3b::getTypeId (void) const [virtual] Returns the type identification instance which uniquely identifies the Coin field class the object belongs to. See also: getClassTypeId(), SoType Implements SoField. void SoMFVec3b::copyFrom (const SoField &f) [virtual] Copy value(s) from f into this field. f must be of the same type as this field. Implements SoField. SbBool SoMFVec3b::isSame (const SoField &f) const [virtual] Check for equal type and value(s). Implements SoField. void SoMFVec3b::deleteAllValues (void) [protected], [virtual] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Implements SoMField. void SoMFVec3b::copyValue (intto, intfrom) [protected], [virtual] This method is used for moving values around internally within a multivalue field. It needs to be overridden in each field so it automatically takes care of running copy contructors where necessary. Implements SoMField. const SbVec3b* SoMFVec3b::getValues (const intstart) const [inline] Returns a pointer to the values array. void SoMFVec3b::initClass (void) [static] Internal method called upon initialization of the library (from SoDB::init()) to set up the type system. Reimplemented from SoMField. void SoMFVec3b::setValues (intstart, intnumarg, const int8_txyz[][3]) Set num vector array elements from the xyz array, reading from index 0 in the given float-triplet vector array and storing values from index start in this SoMFVec3f's array. If start + num is larger than the current number of elements in the SoMFVec3f field, this method will automatically expand the field to accommodate all given float-vector element values. void SoMFVec3b::set1Value (intidx, int8_tx, int8_ty, int8_tz) Set the vector at idx. void SoMFVec3b::set1Value (intidx, const int8_txyz[3]) Set the vector at idx. void SoMFVec3b::setValue (int8_tx, int8_ty, int8_tz) Set this field to contain a single vector with the given element values. void SoMFVec3b::setValue (const int8_txyz[3]) Set this field to contain a single vector with the given element values. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoMFVec3b(3)
All times are GMT -4. The time now is 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy