No its not working it is not making any file ! No output
How to replace row with another row in linux having NA and nucleotide bases
I have file 1:
A1 1 NA
A1 2 NA
A1 3 NA
A1 4 A
A1 5 G
A1 6 T
A1 7 NA
A1 8 NA
A1 9 NA
A2 1 NA
A2 2 NA
A2 3 T
A2 4 NA
And file 2:
A1 4 A
A1 5 C
A1 6 T
A2 3 T
I want to replace row number 4,5,6 and 3 of A2 from file 1 with a value of 4,5,6 and 3 from file 2
Expected Output in new file3:-
A1 1 NA
A1 2 NA
A1 3 NA
A1 4 A
A1 5 C
A1 6 T
A1 7 NA
A1 8 NA
A1 9 NA
A2 1 NA
A2 2 NA
A2 3 T
A2 4 NA
I want to try this in Linux. I tried googling but I could not find better answers.
I tried in linux.
diff file2 file1
join -a 2 file2 file1 | cut -d ' ' -f -2
But i am not getting answers
• 3,287 views
•
link
1 answer
you can use awk:
cat file2 file1 | awk '!seen[$1,$2]++' | sort -k 1V,1 -k 2n,2 > result
Output:
A1 1 NA
A1 2 NA
A1 3 NA
A1 4 A
A1 5 C
A1 6 T
A1 7 NA
A1 8 NA
A1 9 NA
A2 1 NA
A2 2 NA
A2 3 T
A2 4 NA
• 1 views
•
link
Log in to answer this question.