Sponsored Content
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 Post 302774729 by anbu23 on Sunday 3rd of March 2013 01:33:50 AM
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:
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
af_sets(3)						    Attribute Filesystem (AtFS) 						af_sets(3)

NAME
af_initset, af_nrofkeys, af_setgkey, af_setaddkey, af_setrmkey, af_setposrmkey, af_sortset, af_subset, af_copyset, af_intersect, af_union, af_diff - AtFS operations on key sets SYNOPSIS
#include <atfs.h> int af_initset (Af_set *set) int af_nrofkeys (Af_set *set) int af_setgkey (Af_set *set, int position, Af_key *key) int af_setaddkey (Af_set *set, int position, Af_key *key) int af_setrmkey (Af_set *set, Af_key *key) int af_setposrmkey (Af_set *set, int position) int af_sortset (Af_set *set, char *attrname) int af_subset (Af_set *set, Af_attrs *attrbuf, Af_set *subset) int af_copyset (Af_set *source, Af_set *destination) int af_intersect (Af_set *set1, Af_set *set2, Af_set *newset) int af_union (Af_set *set1, Af_set *set2, Af_set *newset) int af_diff (Af_set *set1, Af_set *set2, *Af_set newset) DESCRIPTION
Sets in AtFS are ordered collections of keys. The structure of sets is the following typedef struct { int af_nkeys; int af_setlen; Af_key *af_klist; } Af_set; The list of keys in a set is a linear list, residing in allocated memory. The list has no holes, so that positions 0 through af_nkeys-1 are occupied with valid keys. Set functions returning a set require a pointer to an empty set structure as argument. af_initset initializes a set. af_nrofkeys returns the number of valid keys in the given set. af_setgkey delivers the filekey, stored at position position in the identified set. The result is passed in the buffer key. Typically you use af_setgkey to run through a set and perform a special action on each key. The following code sequence does this job: Af_key key; Af_set set; af_initset (&set); ... for (i = 0; i < af_nrofkeys (&set); i++) { af_setgkey (&set, i, &key); /* process key */ ... } af_setaddkey introduces a new filekey to an existing set at the given position. All following keys are moved back by one position. The constant AF_LASTPOS given as position argument leads to adding the new filekey at the end of the set. af_setrmkey (af_setposrmkey) removes the given filekey (the filekey at position position) from the specified set. Holes generated by delet- ing single keys from a set are eliminated by condensing the set. All following keys are moved one position forth in the set. af_sortset sorts a given set of object keys by the values of the named attribute. The set is sorted in increasing order. Increasing order means, that the lowest value occurs first in the set. Af_user structures are compared by username first and by userdomain, if the names are equal (user host will not be taken into account). Version numbers are ordered in natural order, busy versions first. In atfs.h you can find a list of attribute names naming the standard attributes. All other attribute names are presumed to be user defined attributes. While sorting by the values of an user defined attribute, all ASOs that do not have the named attribute are added at the end of the resulting (sorted) set. Sorting of user defined attributes with multiple values bases on simple text comparison with the order of the values taken as it is. The length of the given attribute name is limited. This limit is defined by the constant AF_UDANAMLEN in atfs.h. af_subset does a retrieve operation (similar to af_find - manual page af_retrieve(3)) on a given set of object keys. Af_subset takes an attribute buffer (attrbuf) with all desired attributes set to an appropriate value as argument. The attribute buffer should be initialized by af_initattrs (manual page af_retrieve(3)) beforehand. af_subset returns it's result in a new set, the original set remains unchanged. af_copyset for copying sets (really! =:-). af_intersect, af_union and af_diff build intersections, unions, and differences between two sets. The result is a new set, where all keys taken from the first argument set (set1) occur first, and the keys from the second argument set (set2) afterwards. You may gibe one of set1 or set2 as resultset. In that case, the original set get lost and is dropped implicitely. Sets generated by af_copyset, af_subset, af_intersect, af_union, or af_diff should be released by af_dropset as soon as they are not used any longer. SEE ALSO
af_retrieve(3) DIAGNOSTICS
Upon error, -1 or a nil pointer (depending on the return type) is returned and af_errno is set to the corresponding error number. AtFS-1.71 Fri Jun 25 14:33:20 1993 af_sets(3)
All times are GMT -4. The time now is 06:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy