Sponsored Content
Top Forums Shell Programming and Scripting awk to print field from lookup file in output Post 302980142 by rangarasan on Wednesday 24th of August 2016 12:22:57 PM
Old 08-24-2016
You are almost done with it.

Code:
awk '                   
    NR == FNR {min[$1]=$3; max[$1]=$4; Gene[$1]=$NF; next}
    {                
        for (id in min) 
            if (min[id] < $2 && $2 < max[id]) {
                print $0, id, Gene[id]
                break              
            }
    }                                     
' search lookup > out

Cheers,
Ranga
This User Gave Thanks to rangarasan For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using awk or sed to print output from one file

dear i have one file regarding >abshabja>sdksjbs>sknakna>snajxcls so i want to be output like >abshabja >sjkabjb >sknakna >snajxcls Any using awk or sed will help thanks (2 Replies)
Discussion started by: cdfd123
2 Replies

2. Shell Programming and Scripting

awk command : To print the output to a file

half of the problem is already solved with the help of bartus11 suggestion I have a txt file having rows and coulmns, i want to perform some operation on a specific coulmn starting from a specific line. 50.000000 1 1 1 1000.00000 1000.00000 ... (5 Replies)
Discussion started by: shashi792
5 Replies

3. UNIX for Dummies Questions & Answers

Multiple Column print after lookup using NR==FNR (awk)

foo.txt FAMID IID AFF SEX Group AgeCat Dis1 Dis2 Dis3 Dis4 Dis5 Dis6 Dis6 AMD0001 Mayo_49542 1 2 AMD 8 1 1 1 1 1 1 1 AMD0002 Mayo_49606 1 1 AMD 3 1 1 1 1 ... (7 Replies)
Discussion started by: genehunter
7 Replies

4. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

5. UNIX for Dummies Questions & Answers

Help with AWK - Compare a field in a file to lookup file and substitute if only a match

I have the below 2 files: 1) Third field from file1.txt should be compared to the first field of lookup.txt. 2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt. 3)Else just print the line from file1.txt. File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies

6. Shell Programming and Scripting

File field to replace lookup from another file

Hi All, I don't know how to fast do this field replace that need lookup from another file to form the update result:confused: I want to do it by general shell script Can anyone help to solve it ? Thanks for your kindly reply in advance. CK (0 Replies)
Discussion started by: ckwong99
0 Replies

7. UNIX for Dummies Questions & Answers

Lookup field in map file

Hi, I have two questions which I would massively appreciate help with. 1. I am trying to insert a field into a file similar to the vlookup function in excel. In column 2 is a gene id for which i would like to insert the full name in the adjacent column. I have a map file (map.file) which... (1 Reply)
Discussion started by: genehersh
1 Replies

8. Shell Programming and Scripting

Lookup field values in two fixed format file in UNIX - not working

I have 2 fixed length files input#1 & input#2. I want to match the rows based on the value in position 37-50 in both files (pos 37-50 will have same value in both files). If any matching record is found then cut the value against company code & Invoice number from input file #1 (position 99 until... (3 Replies)
Discussion started by: Lingaraju
3 Replies

9. Shell Programming and Scripting

awk to lookup stored variable in file and print matching line

The bash bash below extracts the oldest folder from a directory and stores it in filename That result will match a line in bold in input. In the matching line there is an_xxx digit in italics that (once the leading zero is removed) will match a line in link. That is the lint to print in output.... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

Using awk to print output based on first field.

Hi Folks, I have one requirement, There is one file, which contains two fields. Based on first field, I need to print an output. Example will be more suitable. Input file like this. abc 5 abc 10 xyz 6 xyz 9 xyz 10 mnp 10 mnp 12 mnp 6 (2 Replies)
Discussion started by: Raza Ali
2 Replies
ADD(2)								System Calls Manual							    ADD(2)

NAME
add, sub, mul, div, raddp, rsubp, rmul, rdiv, rshift, inset, rcanon, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, Dx, Dy, Pt, Rect, Rpt - arithmetic on points and rectangles SYNOPSIS
#include <u.h> #include <libc.h> #include <libg.h> Point add(Point p, Point q) Point sub(Point p, Point q) Point mul(Point p, int a) Point div(Point p, int a) Rectangle raddp(Rectangle r, Point p) Rectangle rsubp(Rectangle r, Point p) Rectangle rmul(Rectangle r, int a) Rectangle rdiv(Rectangle r, int a) Rectangle rshift(Rectangle r, int a) Rectangle inset(Rectangle r, int n) Rectangle rcanon(Rectangle r) int eqpt(Point p, Point q) int eqrect(Rectangle r, Rectangle s) int ptinrect(Point p, Rectangle r) int rectinrect(Rectangle r, Rectangle s) int rectXrect(Rectangle r, Rectangle s) int rectclip(Rectangle *rp, Rectangle b) int Dx(Rectangle r) int Dy(Rectangle r) Point Pt(int x, int y) Rectangle Rect(int x0, int y0, int x1, int y1) Rectangle Rpt(Point p, Point q) DESCRIPTION
The functions Pt, Rect and Rpt construct geometrical data types from their components. These are implemented as macros. Add returns the Point sum of its arguments: Pt(p.x+q.x, p.y+q.y). Sub returns the Point difference of its arguments: Pt(p.x-q.x, p.y-q.y). Mul returns the Point Pt(p.x*a, p.y*a). Div returns the Point Pt(p.x/a, p.y/a). Raddp returns the Rectangle Rect(add(r.min, p), add(r.max, p)); rsubp returns the Rectangle Rpt(sub(r.min, p), sub(r.max, p)). Rmul returns the Rectangle Rpt(mul(r.min,a), mul(r.max,a)); Rdiv returns the Rectangle Rpt(div(r.min,a), div(r.max,a)). Rshift returns the rectangle r with all coordinates either left-shifted or right-shifted by a, depending on whether a is positive or nega- tive, respectively. Inset returns the Rectangle Rect(r.min.x+n, r.min.y+n, r.max.x-n, r.max.y-n). Rcanon returns a rectangle with the same extent as r, canonicalized so that min.x <= max.x, and min.y <= max.y. Eqpt compares its argument Points and returns 0 if unequal, 1 if equal. Eqrect does the same for its argument Rectangles. Ptinrect returns 1 if p is a point within r, and 0 otherwise. Rectinrect returns 1 if all the pixels in r are also in s, and 0 otherwise. RectXrect returns 1 if r and s share any point, and 0 otherwise. Rectclip clips in place the Rectangle pointed to by rp so that it is completely contained within b. The return value is 1 if any part of *rp is within b. Otherwise, the return value is 0 and *rp is unchanged. The functions Dx and Dy give the width (x) and height (y) of a Rectangle. They are implemented as macros. SOURCE
/sys/src/libg SEE ALSO
graphics(2) ADD(2)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy