Back (Current repo: scraps)

random scraps and notes that are useful to me
To clone this repository:
git clone https://git.viktor1993.net/scraps.git
Log | Download | Files | Refs

compare_single_columns.awk (342B)


#!/usr/bin/awk
#USAGE: awk -f compare_single_columns.awk <file1> <file2>
BEGIN{
    print "Only in "ARGV[2]":";
}
(NR==FNR) {
    a[$0]++;next
}
{
    if($0 in a) {
        a[$0]="-1"
    } else {
        print $0
    }
}

END{
    print "Only in "ARGV[1]":";
    for(x in a) {
        if(a[x]!="-1") {
            print x;
        }
    }
}