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
Hello,
I want to extract columns from file2 to file3 by matching ids between file1 and file2.
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.
I have two files with N number of columns
File1:
A 1 2 3 ....... Na1
B 2 3 4 ....... Nb1
File2:
A 2 2 4 ....... Na2
B 1 3 4 ....... Nb2
i want a output where 1st column value from File1 will be subtracted from 1st column of File2, and this way till column N as shown below:
A -1 0 -1 ........ (Na1-Na2)
B 1 0 0 ........
Hi Solved these kind of issues using these codes But these are not wrking for my attached files can anybody check........
Code:
awk 'NR==FNR{X[$1]++;next}{if(X[$1]){print}}' file1 file2
Code:
awk 'NR==FNR{X[$1]=$0;next}{n=split($1,P," ");sub($1,"",$0);for(i=1;i<=n;i++){if(X[P[i]]){print P[i],$0}}}' file1 FS="\t" file2
Please let me know any changes for
Hi guys,
can someone please help me with a vlookup utility in shell script that does the work similar to Excel.
Ex:
If File1.txt is
1
2
11
4
12
and File2.txt is
1 tab1
2 tab2
3 tab3
4 tab4
5 tab5
then the utility should create File3.txt with the below mentioned output:
1 tab1
2 tab2
11
4 tab4
12
the separator between columns will be tab(\t).
Also, is it possible, if File1.txt and File2.txt h
Hi,
I need to compare multiple columns from 2 files.
I can, for example, have these 2 files:
file1:
Code:
col1, col2, col3,col4
a,1,4,7
b,2,5,8
c,3,6,9
file2:
Code:
col1, col2, col3,col4
a,2,3,2
b,5,7,5
c,1,9,8
As a result, I need for example the difference between the columns 2 and 4:
Code:
col2, col4
1,-5
3,-3
-2,-1
I made something that works for comparing 1 column, but I w
I want to compare two files. I think using grep is the way to go but I do not know how to set this up. Let me show an example:
File1 has 1000 items, File2 has 700 items
I need to take the first item in File1 and search the entire contents of File2 to see if there is a match there. IF there is a match (meaning the same item is in both File1 and File2) then do nothing.
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.