Sponsored Content
Top Forums Shell Programming and Scripting awk to comppare two files using rwo fields Post 302982601 by RavinderSingh13 on Friday 30th of September 2016 02:10:43 PM
Old 09-30-2016
Hello cmccabe,

Could you please try following and let me know if this helps.
Code:
awk 'FNR==NR{A[$3]=$1 FS $3 FS $4;next} ($2 in A){print A[$2],$3,$4,$5,$6}'  Input_file1   Input_file2

Output will be as follows.
Code:
chr1 11796321 MTHFR G 0 WILD ADP=1026
chr1 169549811 F5 C 0 WILD ADP=940
chr1 173917078 SERPINC1 C 0 WILD ADP=501
chr2 48962782 FSHR C T HET ADP=1665
chr4 121696962 ANXA5 C T HET ADP=212
chr4 121697011 ANXA5 A 0 WILD ADP=184
chr4 121697037 ANXA5 T 0 WILD ADP=111
chr4 121697037 ANXA5 tccc 0 INDEL AINDEL
chr4 121697056 ANXA5 C 0 WILD ADP=112
chr11 46739505 F2 G 0 WILD ADP=202
chr13 20189511 GJB2 C 0 WILD ADP=326
chr13 20189547 GJB2 C 0 WILD ADP=3

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk print fields to multiple files?

I am trying to print the output of a command to two separate files. Is it possible to use awk to print $1 to one file and $2 to another file? Thanks in advance! (1 Reply)
Discussion started by: TheCrunge
1 Replies

2. Shell Programming and Scripting

AWK Matching Fields and Combining Files

Hello! I am writing a program to run through two large lists of data (~300,000 rows), find where rows in one file match another, and combine them based on matching fields. Due to the large file sizes, I'm guessing AWK will be the most efficient way to do this. Overall, the input and output I'm... (5 Replies)
Discussion started by: Michelangelo
5 Replies

3. Shell Programming and Scripting

Compare fields in 2 files using AWK

Hi unix gurus, I have a urgent requirement, I need to write a AWK script to compare each fields in 2 files using AWK. Basically my output should be like this. file1 row|num1|num2|num3 1|one|two|three 2|one|two|three file2 row|num1|num2|num3 1|one|two|three 2|one|two|four ... (5 Replies)
Discussion started by: rashmisb
5 Replies

4. Shell Programming and Scripting

AWK Compare files, different fields, output

Hi All, Looking for a quick AWK script to output some differences between two files. FILE1 device1 1.1.1.1 PINGS device1 2.2.2.2 PINGS FILE2 2862 SITE1 device1-prod 1.1.1.1 icmp - 0 ... (4 Replies)
Discussion started by: stacky69
4 Replies

5. Shell Programming and Scripting

AWK: merge two files and replace some fields

Need some code tweak: awk 'END { for (i=1; i<=n; i++) if (f2]) print f2] } NR == FNR { f2 = $1] = $0 next } $1 in f2 { delete f2 }1' FS=, OFS=, 2.csv 1.csv > 3.csvfile 1.csv have: $1,$2,$3,$4,$5,$6,$7,$8,$9...... file 2.csv have: $1,$2,$3,$4,$5,$6 (2 Replies)
Discussion started by: u10
2 Replies

6. Programming

comparing two fields from two different files in AWK

Hi, I have two files formatted as following: File 1: (user_num_ID , realID) (the NR here is 41671) 1 cust_034_60 2 cust_80_91 3 cust_406_4 .. .. File 2: (realID , clusterNumber) (total NR here is 1000) cust_034_60 2 cust_406_4 3 .. .. (11 Replies)
Discussion started by: amarn
11 Replies

7. Shell Programming and Scripting

awk program to join 2 fields of different files

Hello Friends, I just need a small help, I need an awk program which can join 2 fields of different files which are having one common field into one file. File - 1 FileName~Size File- 2 FileName~Date I need the output file in the following way O/P- File FileName~Date~Size For... (4 Replies)
Discussion started by: abhisheksunkari
4 Replies

8. Shell Programming and Scripting

Sum fields of different files using awk

I'm trying to sum each field of the second column over many different files. For example: file1: file2: 1 5 1 5 2 6 2 4 3 5 3 3 To get: file3 1 10 2 10 3 8 I found answer when there are only 2 files as... (10 Replies)
Discussion started by: rogeriog.em
10 Replies

9. UNIX for Beginners Questions & Answers

Awk: matching multiple fields between 2 files

Hi, I have 2 tab-delimited input files as follows. file1.tab: green A apple red B apple file2.tab: apple - A;Z Objective: Return $1 of file1 if, . $1 of file2 matches $3 of file1 and, . any single element (separated by ";") in $3 of file2 is present in $2 of file1 In order to... (3 Replies)
Discussion started by: beca123456
3 Replies

10. 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
ns_adp_puts(3aolserver) 				    AOLserver Built-In Commands 				   ns_adp_puts(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
ns_adp_append, ns_adp_close, ns_adp_dump, ns_adp_flush, ns_adp_puts, ns_adp_stream, ns_adp_tell, ns_adp_trunc, ns_puts - ADP output com- mands SYNOPSIS
ns_adp_append string ?string ...? ns_adp_close ns_adp_dump ns_adp_flush ns_adp_puts ?-nonewline? string ns_adp_stream ns_adp_tell ns_adp_trunc ?length? ns_puts ?-nonewline? string _________________________________________________________________ DESCRIPTION
These commands enable adding to and manipulation of the ADP output buffer. See ns_adp for an overview on ADP pages. ns_adp_append string ?string ...? This command appends one or more strings to the ADP output buffer. For the case of a single argument, it is equivalent to ns_adp_puts -nonewline string. ns_adp_close This command can be used to flush and close the underlying HTTP connection. ADP execution continues after the connection is closed; any text appended to the output buffer after the close is simply discarded when processing is complete. ns_adp_dump This command returns the text of the ADP buffer. ns_adp_flush This command flushes the contents of the ADP buffer to the current connection or file channel. It will raise a Tcl exception if the underlying flush failed, for example, if the HTTP connection is closed or the channel write failed. Flushed content is returned in "chunked-encoding" format if the HTTP protocol version is at least 1.1 (normally the case for all modern browsers). A call to ns_adp_flush is not normally needed except for specialized applications as all content is automatically flushed at the end of a con- nection or on buffer overflow. (see ns_adp_ctl bufsize for details on buffer mangement). ns_adp_puts ?-nonewline? string This function appends the specified string to the ADP buffer. Unless the optional -nonewline argument is used, a newline will be appended to the page after the string. Note that the argument to ns_adp_puts is a single string unlike ns_adp_append which takes a variable number of strings to append. ns_adp_stream This function begins streaming mode for the ADP. All data currently in the ADP output buffer is flushed and any subsequent data will be output directly to the connection. It is equivalent to an ns_adp_flush followed by an ns_adp_ctl bufsize 0. ns_adp_tell This function returns the total number of bytes current in the ADP buffer. A buffer overflow or direct call to ns_adp_flush will reset this counter to zero so the result of ns_adp_tell may not return the total number of bytes eventually sent. ns_adp_trunc ?length? This function can be used to truncate output buffer to the requested size. This can be useful to trim unintended white space or to clear a result and generate an error message. Note that content already streamed to the client, if any, cannot be truncated. ns_puts ?-nonewline? string This command is a deprecated name for ns_adp_puts. SEE ALSO
ns_adp(n), ns_adp_include(n) KEYWORDS
ADP, dynamic pages AOLserver 4.5 ns_adp_puts(3aolserver)
All times are GMT -4. The time now is 02:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy