Join without removing unique lines in Linux
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a table A:
1 n m n ...
2 m n m ...
3 n m n ...
4 m n m ...
5 n m n ...
I have a table B:
1 A
3 B
5 C
I want to join the column 2 of table B with table A by matching column 1 of both tables, without removing the unique lines in table A to get the following (for no matches write a "NA"):
1 A n m n ...
2 NA m n m ...
3 B n m n ...
4 NA m n m ...
5 C n m n ...
text-processing join
add a comment |Â
up vote
1
down vote
favorite
I have a table A:
1 n m n ...
2 m n m ...
3 n m n ...
4 m n m ...
5 n m n ...
I have a table B:
1 A
3 B
5 C
I want to join the column 2 of table B with table A by matching column 1 of both tables, without removing the unique lines in table A to get the following (for no matches write a "NA"):
1 A n m n ...
2 NA m n m ...
3 B n m n ...
4 NA m n m ...
5 C n m n ...
text-processing join
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a table A:
1 n m n ...
2 m n m ...
3 n m n ...
4 m n m ...
5 n m n ...
I have a table B:
1 A
3 B
5 C
I want to join the column 2 of table B with table A by matching column 1 of both tables, without removing the unique lines in table A to get the following (for no matches write a "NA"):
1 A n m n ...
2 NA m n m ...
3 B n m n ...
4 NA m n m ...
5 C n m n ...
text-processing join
I have a table A:
1 n m n ...
2 m n m ...
3 n m n ...
4 m n m ...
5 n m n ...
I have a table B:
1 A
3 B
5 C
I want to join the column 2 of table B with table A by matching column 1 of both tables, without removing the unique lines in table A to get the following (for no matches write a "NA"):
1 A n m n ...
2 NA m n m ...
3 B n m n ...
4 NA m n m ...
5 C n m n ...
text-processing join
edited Jan 23 at 7:26
ñÃÂsýù÷
15.2k92462
15.2k92462
asked Jan 23 at 3:15
Johnny Tam
1208
1208
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
From man join
-a FILENUM
also print unpairable lines from file FILENUM, where FILENUM is
1 or 2, corresponding to FILE1 or FILE2
-e EMPTY
replace missing input fields with EMPTY
so
join -a1 -e 'NA' -o 0,2.2,1.2,1.3,1.4 A B
1 A n m n
2 NA m n m
3 B n m n
4 NA m n m
5 C n m n
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
From man join
-a FILENUM
also print unpairable lines from file FILENUM, where FILENUM is
1 or 2, corresponding to FILE1 or FILE2
-e EMPTY
replace missing input fields with EMPTY
so
join -a1 -e 'NA' -o 0,2.2,1.2,1.3,1.4 A B
1 A n m n
2 NA m n m
3 B n m n
4 NA m n m
5 C n m n
add a comment |Â
up vote
3
down vote
accepted
From man join
-a FILENUM
also print unpairable lines from file FILENUM, where FILENUM is
1 or 2, corresponding to FILE1 or FILE2
-e EMPTY
replace missing input fields with EMPTY
so
join -a1 -e 'NA' -o 0,2.2,1.2,1.3,1.4 A B
1 A n m n
2 NA m n m
3 B n m n
4 NA m n m
5 C n m n
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
From man join
-a FILENUM
also print unpairable lines from file FILENUM, where FILENUM is
1 or 2, corresponding to FILE1 or FILE2
-e EMPTY
replace missing input fields with EMPTY
so
join -a1 -e 'NA' -o 0,2.2,1.2,1.3,1.4 A B
1 A n m n
2 NA m n m
3 B n m n
4 NA m n m
5 C n m n
From man join
-a FILENUM
also print unpairable lines from file FILENUM, where FILENUM is
1 or 2, corresponding to FILE1 or FILE2
-e EMPTY
replace missing input fields with EMPTY
so
join -a1 -e 'NA' -o 0,2.2,1.2,1.3,1.4 A B
1 A n m n
2 NA m n m
3 B n m n
4 NA m n m
5 C n m n
answered Jan 23 at 3:27
steeldriver
31.5k34979
31.5k34979
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418993%2fjoin-without-removing-unique-lines-in-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password