If col1 and col2 of any line in both of two files in two files match, col1 and col2


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers If col1 and col2 of any line in both of two files in two files match, col1 and col2
Prev   Next
# 2  
Old 03-03-2013
Code:
$ awk ' NR == FNR { arr[$1$2]=1; next } arr[$2$1] {print $1, $2} ' file1 file2
m.160140_g.160140 ACYPI46488-PA_product:GLE

This User Gave Thanks to anbu23 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies

2. Shell Programming and Scripting

Comparing two one-line files and selecting what does not match

I have two files. One is consisting of one line, with data separated by spaces and each number appearing only once. The other is consisting of one column and multiple lines which can have some numbers appearing more than once. It looks something like this: file 1: 20 700 15 30 file2: 10... (10 Replies)
Discussion started by: maya3
10 Replies

3. Shell Programming and Scripting

Match string from two files and print line

Hi, I have been trying to find help with my issue and I'm thinking awk may be able to do it. I have two files eg file1.txt STRING1 230 400 0.36 STRING2 400 230 -0.13 STRING3 130 349 1 file2.txt CUFFFLINKS 1 1394 93932 . + STRING1 CUFFFLINKS ... (9 Replies)
Discussion started by: zward
9 Replies

4. Shell Programming and Scripting

awk to match field between two files and use conditions on match

I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Discussion started by: cmccabe
3 Replies

5. Shell Programming and Scripting

Adding info to end of line if two columns match from files with different separators

I have two files (csv and vcf) which look exactly like this S1.csv func,gene,start,info "exonic","AL","2309","het" "exonic","NEF","6912","hom"S1.vcf ##fileinfo #CHROM POS ID INFO chr1 4567 rs323211 1/1:84,104,99 chr4 2309 rs346742 1/1:27,213,90 chr6 5834 ... (5 Replies)
Discussion started by: Sarah_19
5 Replies

6. Shell Programming and Scripting

Merging data from col 3 to col2 with awk or sed

Dear Friends, I have a file in which lists State and Phone numbers. Does anybody have a solution in which to take the data from col3 and place it on col2? AK 2988421640 9077467107 AK 2998266711 2069239034 AK 2983804242 2069239034 AK 2960407849 AK ... (3 Replies)
Discussion started by: liketheshell
3 Replies

7. Shell Programming and Scripting

List files only when a certain number of files match

Hi, I have many files named CCR20110720011001.CTRD CCR20110720011501.CTRD CCR20110720012001.CTRD CCR20110720012501.CTRD CCR20110720021001.CTRD ... (9 Replies)
Discussion started by: shadyfright
9 Replies

8. Shell Programming and Scripting

Awk - Count instances of a number in col1 and put results in a col2 (new) of diff file

I have 2 files as follows: filename1: : 6742 /welcome/mundial98_ahf1_404.htm 1020 6743 /welcome/mundial98_ahf1_404.htm 2224 6744 /welcome/mundial_ef1_404.htm 21678 6745 /welcome/mundial_if_404.htm 4236 6746 /welcome/mundial_lf1_404.htm 21678 filename2: 6746 894694763 1... (2 Replies)
Discussion started by: jontjioe
2 Replies

9. Shell Programming and Scripting

Replace a column with a value conditional on a value in col1

Hi, Perhaps a rather simple problem...? I have data that looks like this. BPC0013 ANNUL_49610 0 0 1 1 BPC0014 ANNUL_49642 0 0 2 1 BPC0015 ANNUL_49580 0 0 1 1 BPC0016 ANNUL_49596 0 0 2 1 BPC0017 VULGO_49612 0 0 1 1 BPC0018 ANNUL_49628 0 0 1 1 BPC0019 ANNUL_49692 0 0 2 1 170291_HMG... (4 Replies)
Discussion started by: genehunter
4 Replies

10. UNIX for Dummies Questions & Answers

minus col1 and col2

my file looks like this: 101928 101943 101928 101944 101929 101943 101929 101943 101929 102044 i want to insert bc to get answer like this: 101928 101943 000015 101928 101944 000016 101929 101943 000013 101929 101943 000014 101929 102044 000115 total 000173 my... (3 Replies)
Discussion started by: tjmannonline
3 Replies
Login or Register to Ask a Question
struct::set(n)							Tcl Data Structures						    struct::set(n)

__________________________________________________________________________________________________________________________________________________

NAME
struct::set - Procedures for manipulating sets SYNOPSIS
package require Tcl 8.0 package require struct::set ?2.2.3? ::struct::set empty set ::struct::set size set ::struct::set contains set item ::struct::set union ?set1...? ::struct::set intersect ?set1...? ::struct::set difference set1 set2 ::struct::set symdiff set1 set2 ::struct::set intersect3 set1 set2 ::struct::set equal set1 set2 ::struct::set include svar item ::struct::set exclude svar item ::struct::set add svar set ::struct::set subtract svar set ::struct::set subsetof A B _________________________________________________________________ DESCRIPTION
The ::struct::set namespace contains several useful commands for processing finite sets. It exports only a single command, struct::set. All functionality provided here can be reached through a subcommand of this command. Note: As of version 2.2 of this package a critcl based C implementation is available. This implementation however requires Tcl 8.4 to run. COMMANDS
::struct::set empty set Returns a boolean value indicating if the set is empty (true), or not (false). ::struct::set size set Returns an integer number greater than or equal to zero. This is the number of elements in the set. In other words, its cardinality. ::struct::set contains set item Returns a boolean value indicating if the set contains the element item (true), or not (false). ::struct::set union ?set1...? Computes the set containing the union of set1, set2, etc., i.e. "set1 + set2 + ...", and returns this set as the result of the com- mand. ::struct::set intersect ?set1...? Computes the set containing the intersection of set1, set2, etc., i.e. "set1 * set2 * ...", and returns this set as the result of the command. ::struct::set difference set1 set2 Computes the set containing the difference of set1 and set2, i.e. ("set1 - set2") and returns this set as the result of the command. ::struct::set symdiff set1 set2 Computes the set containing the symmetric difference of set1 and set2, i.e. ("(set1 - set2) + (set2 - set1)") and returns this set as the result of the command. ::struct::set intersect3 set1 set2 This command is a combination of the methods intersect and difference. It returns a three-element list containing "set1*set2", "set1-set2", and "set2-set1", in this order. In other words, the intersection of the two parameter sets, and their differences. ::struct::set equal set1 set2 Returns a boolean value indicating if the two sets are equal (true) or not (false). ::struct::set include svar item The element item is added to the set specified by the variable name in svar. The return value of the command is empty. This is the equivalent of lappend for sets. If the variable named by svar does not exist it will be created. ::struct::set exclude svar item The element item is removed from the set specified by the variable name in svar. The return value of the command is empty. This is a near-equivalent of lreplace for sets. ::struct::set add svar set All the element of set are added to the set specified by the variable name in svar. The return value of the command is empty. This is like the method include, but for the addition of a whole set. If the variable named by svar does not exist it will be created. ::struct::set subtract svar set All the element of set are removed from the set specified by the variable name in svar. The return value of the command is empty. This is like the method exclude, but for the removal of a whole set. ::struct::set subsetof A B Returns a boolean value indicating if the set A is a true subset of or equal to the set B (true), or not (false). REFERENCES
BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category struct :: set of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
cardinality, difference, emptiness, exclusion, inclusion, intersection, membership, set, symmetric difference, union CATEGORY
Data structures COPYRIGHT
Copyright (c) 2004-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net> struct 2.2.3 struct::set(n)