Reputation: 29448
One file has 3 columns and looks like this:
1 249250621 225280621
2 243199373 238207373
3 198022430 194797140
4 191154276 187661676
5 180915260 177695260
6 171115067 167395067
7 159138663 155353663
8 146364022 142888922
9 141213431 120143431
10 135534747 131314747
11 135006516 131129516
12 133851895 130481895
13 115169878 95589878
14 107349540 88289540
15 102531392 81694769
16 90354753 78884753
17 81195210 77795210
18 78077248 74657248
19 59128983 55808983
20 63025520 59505520
21 48129895 35108702
22 51304566 34894566
X 155270560 151100560
Y 59373566 25653566
My other file looks like:
5677533
4506000
2272564
2753699
4015846
2163243
3812595
2885199
8064159
3522086
2006115
1490517
1072244
1423429
3009679
2705191
1479591
800436
929876
648000
347993
972862
7812943
9660863
When I try
paste file1.txt file2.txt > file3.txt
I get:
1 567753321 225280621
2 450600073 238207373
3 227256430 194797140
4 275369976 187661676
5 401584660 177695260
6 216324367 167395067
7 381259563 155353663
8 288519922 142888922
9 806415931 120143431
10 352208647 131314747
11 200611516 131129516
12 149051795 130481895
13 107224478 95589878
14 142342940 88289540
15 300967992 81694769
16 27051913 78884753
17 14795910 77795210
18 80043648 74657248
19 92987683 55808983
20 64800020 59505520
21 34799395 35108702
22 97286266 34894566
X 781294360 151100560
Y 96608636 25653566
The data from file2.txt overwrites the 2nd column in file 1. I want the data in file2.txt to be appended to the end in a new column, separated by a tab in file1.txt into the new file3.txt. But it does not seem to be working. Thoughts? Thanks.
Edit: For file2, I can create it with the same first column index 1-22, x, y. But then when I try to join, it doesn't work either. This is my output on join:
1 249250621 225280621
5677533
2 243199373 238207373
4506000
3 198022430 194797140
2272564
4 191154276 187661676
2753699
5 180915260 177695260
4015846
6 171115067 167395067
2163243
7 159138663 155353663
3812595
8 146364022 142888922
2885199
9 141213431 120143431
8064159
10 135534747 131314747
3522086
11 135006516 131129516
2006115
12 133851895 130481895
1490517
13 115169878 95589878
1072244
14 107349540 88289540
1423429
15 102531392 81694769
3009679
16 90354753 78884753
2705191
17 81195210 77795210
1479591
18 78077248 74657248
800436
19 59128983 55808983
929876
20 63025520 59505520
648000
21 48129895 35108702
347993
22 51304566 34894566
972862
X 155270560 151100560
7812943
Y 59373566 25653566 9660863
Upvotes: 4
Views: 1623
Reputation: 52858
Try running dos2unix
on both file1.txt
and file2.txt
first.
==> dos2unix file*.txt
file1.txt: done.
file2.txt: done.
==> paste file1.txt file2.txt > file3.txt
==> cat file3.txt
1 249250621 225280621 5677533
2 243199373 238207373 4506000
3 198022430 194797140 2272564
4 191154276 187661676 2753699
5 180915260 177695260 4015846
6 171115067 167395067 2163243
7 159138663 155353663 3812595
8 146364022 142888922 2885199
9 141213431 120143431 8064159
10 135534747 131314747 3522086
11 135006516 131129516 2006115
12 133851895 130481895 1490517
13 115169878 95589878 1072244
14 107349540 88289540 1423429
15 102531392 81694769 3009679
16 90354753 78884753 2705191
17 81195210 77795210 1479591
18 78077248 74657248 800436
19 59128983 55808983 929876
20 63025520 59505520 648000
21 48129895 35108702 347993
22 51304566 34894566 972862
X 155270560 151100560 7812943
Y 59373566 25653566 9660863
Upvotes: 3