This command taking too long time without any output. My files are tab delimited..
• 0 views
•
link
I have two tab delimited files, one contains list of nodes (file 1) and another file contains list of nodes and its additional details. I need to find nodes (file 1), which are not matching in another file (file 2). Please see example below:
File 1:
NODE_35_length_25224_cov_45.741
NODE_42_length_28456_cov_53.6579
NODE_43_length_25224_cov_33.7544
NODE_226_length_737_cov_1.98094
File 2:
NODE_35_length_25224_cov_45.741 Prodigal:2.6 CDS 58 777 . - 0 ID=LGE0470
NODE_42_length_28456_cov_53.6579 Prodigal:2.6 CDS 58 777 . - 0 ID=LGE0445
OUTPUT:
NODE_43_length_25224_cov_33.7544
NODE_226_length_737_cov_1.98094
grep -vf <(awk -F "\t" '{print $1}' file2) file1
Try to understand what the function does. The core part is grep -v -f, many tutorial on grep out there.
This command taking too long time without any output. My files are tab delimited..
you can use simpler one:
$ cut -f 1 file2.txt | grep -vf - file1.txt
NODE_43_length_25224_cov_33.7544
NODE_226_length_737_cov_1.98094
or using only awk :
$ awk -F "\t" 'NR==FNR{a[$1];next} !($1 in a)' file2.txt file1.txt
NODE_43_length_25224_cov_33.7544
NODE_226_length_737_cov_1.98094
Log in to answer this question.
Please use the formatting bar (especially the

codeoption) to present your post better. I've done it for you this time.Thank you!
with tsv-utils: