Just stumbled upon the most bizarre awk problem. mawk and gawk are showing 2 different results for the same code. Can anyone shed any light?

TIA!

DR

---

[email protected]:/sense/work/feature-summary/debugging$ cat sample.txt
32e49398e024dcb79a319c62ceb213ae3e824f77        2
32e4cb91fdefe6103d73f1d6e43ecd8430f85334        2
32e4cb91fdefe6103d73f1d6e43ecd8430f85334        132
32e5434c41a8e2f0178fd19bd868758af6eb67c0        2
32e56067        10
32e56067        79
32e56122        59
32e57aacfd27f7fde61184052cb35551213c7cd6        5

[email protected]:/sense/work/feature-summary/debugging$ cat ../totals-by-label.awk
#!/usr/bin/awk -f

BEGIN {FS="\t"; prev_label = "";}
{
        curr_label=$1;
        count=$2;
        if (prev_label != "" && curr_label != prev_label) {
                output();
        }
        prev_label=curr_label;
        tot += count;
}
END { output(); }

function output() {
        print prev_label"\t"tot;
        tot = 0;
}

[email protected]:/sense/work/feature-summary/debugging$ cat sample.txt | mawk -f ../totals-by-label.awk
32e49398e024dcb79a319c62ceb213ae3e824f77        2
32e4cb91fdefe6103d73f1d6e43ecd8430f85334        134
32e5434c41a8e2f0178fd19bd868758af6eb67c0        2
32e56122        148
32e57aacfd27f7fde61184052cb35551213c7cd6        5

[email protected]:/sense/work/feature-summary/debugging$ cat sample.txt | gawk -f ../totals-by-label.awk
32e49398e024dcb79a319c62ceb213ae3e824f77        2
32e4cb91fdefe6103d73f1d6e43ecd8430f85334        134
32e5434c41a8e2f0178fd19bd868758af6eb67c0        2
32e56067        89
32e56122        59
32e57aacfd27f7fde61184052cb35551213c7cd6        5
_______________________________________________
Discuss mailing list
[email protected]
http://lists.blu.org/mailman/listinfo/discuss

Reply via email to