I have file1 and file2
I lookup field3 from file2 in field1 of file1 and if there is a match, output field 2,3,5 from file2.
I now want to add field2 of file1 in the output.
I suspect what I have to do is read the entire line of file1 into a 2 dim array? pls help.
Hi Freinds,
i have a file1 as below
file1
Code:
1|ndmf|fdd|d3484|34874
2|jdehf|wru7|478|w489
3|dfkj|wej|484|49894
file2 contains lakhs of records and not in sorted order
i want to retrive only the records from file2 by searcing the first field of file 1
i used
Code:
grep ^1 file2 >out.txt
grep ^2 file2 >>out.txt
grep ^3 file2>>out.txt
this i need to do 3 time
Hello, guys!
I want to find difference between two file according $1. I using the following code, but get wrong results.
Code:
awk -F, 'NR==FNR{A[$1]=$0; next} $1!=A[$1]' file1 file2
I can using the following code get same record between files.
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 example of where in file2 the First Name=John, Email=john.doe@yahoo.com, and Phone Number=111-222-3333.
Hello experts,
I have this problem, I need to match values based on two files, this is what I have:
file1
Code:
1.1
1.2
1.3
5.5
1.4
1.5
1.6
file2
Code:
1 a
2 B
3 C
4 D
5 z
6 F
7 G
8 H
9 I
10 J
11 K
12 L
13 M
14 N
15 O
16 P
17 Q
18 R
19 S
20 T
and the desired output is:
Code:
a
a
a
z
a
a
a
I'm using this code:
Code:
awk 'NR==FNR{a[int($1+.5)];next} $1 in a {print $2}' fil
Code:
cat file1
1 a b c
2 d e f
3 a f r
Code:
cat file2
a c e
output should be
Code:
1
3
means:
if field 1 of file2 matches filed 2 of file1 then print field 1 of file1
I know that it can be done using awk NR=FNR.
But not able to acheive it.
Thanks in advance.
Hi,
Is there any short method to print from a particular field till another filed using awk?
Example File:
Code:
File1
====
1|2|acv|vbc|......|100|342
2|3|afg|nhj|.......|100|346
Expected output:
[code]
File2
====
acv|vbc|.....|100
afg|nhj|.....|100
[code]
In the above example, let say I have 101 fields, I have print line only from 3 field to 100 field.
Is
Code:
awk '{print $3FS
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number following the string "Gene_" in file2.
I'm a little stuck and would be grateful of some advice!
I have three files, two of which contain reference data that I want to add to a line of output in the third file.