Unix join command complexity
Unix join command complexity
Unix join command complexity
With awk you can do: awk ‘ NR==FNR { k[$1]=$2; next } { print $0, k[$1] } ‘ file2.txt file1.txt Note: This awk … Read more
Like this, but it doesn’t include the header line: $ awk ‘{print $1}’ file2.txt | grep -vf – file1.txt 44888 56565 45554 6868 … Read more
One awk solution: awk ‘ FNR == NR { data[ $2 ] = 1; next; } FNR < NR { if ( ! … Read more
intersection of two files according to the first column
Here’s a Bash script that does what you’re looking for. The script’s called mergeAB.bash. #!/bin/bash readarray A < fileA.txt i=0 while read -r … Read more
You could explicitly specify the output format LC_ALL=C join -o0,1.2,2.2 -j1 -a1 -a2 -t’,’ john jane which produces apple,green,red banana,,yellow cherry,red,yellow kiwi,,green orange,orange, … Read more
terdon mentions doing it with coreutils only, a humble suggestion: (echo CHR SNP MAF P paste <(tail -n +2 file2) <(grep ALL file1) … Read more
This is simple task for awk: awk -F’:’ -vOFS=’:’ ‘NR==FNR{a[$2]=$0;next}{print $0,a[$2]}’ file2 file1 First we set : as field separator both for input … Read more
You could do it with awk alone: $ awk ‘FNR==NR { o[$2]=$1; next } !o[$2] { print $0, “NEW”; next } $1!=o[$2] { … Read more