Hi guyz
Excuse me for posting simple question
I tried join and sort and other perl commands but failed
I have 2 files. 1st file contain single column with around 6000 values (rows).
Second file contain 2 columns 1st column is the same column (in 1st file) but randomly ordered and second column filled with some xyz symbols. The inputs are like
Input 1
1st File
Col1
1434322
1143255
1232444
Input 2
2nd File
Col1tabCol2
B]Col1tabCol2
1232444tabxyzda
1143255tabwerftt
1434322tabtshyhs
OUTPUT
3rd File
Col1tabCol2tabCol3
1434322tab1434322tabtshyhs
1143255tab1143255tabwerftt
1232444tab1232444tabxyzda
$
$ sort input1 > input1_sorted; sort input2 > input2_sorted
$
$ cat input1_sorted
1143255
1232444
1434322
$
$ cat input2_sorted
1143255 werftt
1232444 xyzda
1434322 tshyhs
$
$ join -o 1.1,2.1,2.2 input1_sorted input2_sorted
1143255 1143255 werftt
1232444 1232444 xyzda
1434322 1434322 tshyhs
$
$
tyler_durden
Hi already did some thing like that I dont know why it's not working
I'm here by attaching the test input files.
Could you plz check where I'm going wrong.
Thanx
There are a lot of empty space/tab delimited files in INPUT2.txt
sed '/^ \t $/d' INPUT1.txt > f1.txt
sed '/^ \t $/d' INPUT2.txt > f2.txt
sort -k 1,1 f1.txt > INPUT1.txt
sort -k 1,1 f2.txt > INPUT2.txt
join -o 1.1,2.1,2.2 INPUT1.txt INPUT2.txt > output.txt
cheers,
Devaraj Takhellambam
Devaraj Takhellambam
Try awk:
awk 'NR==FNR{_[$1]=$1;next}$1 in _{print _[$1],$0}' INPUT1.txt INPUT2.txt