Q:

getting the number of unique values

I have some text files with two columns. first column is the position of amino acids and the second column is the name of amino acids.I would like to get the total number of each amino acids from all files. I need only unique values. In the following example, total no:of LEU is 2 (one from file1 and the other from file2). Your suggestions would be appreciated!
file1
54   LEU
54   LEU
78   VAL
112  ALA
78   VAL

file 2 
54   LEU
113  ALA
113  ALA
12   ALA
112  ALA

desired output   
total no:of LEU - 2
total no:of VAL - 1
total no:of ALA - 4

A:

If you only have two files, just use awk:
awk '{ a[$2]++ } END { for (i in a) print "total no:of", i, a[i] }' <(awk '!a[$1,$2]++' file1) <(awk '!a[$1,$2]++' file2)

If you have many, many files, try this awk script. Run like:
awk -f script.awk file{1..200}

Contents of script.awk:
{
    a[FILENAME,$1,$2]
}

END {
    for (i in a) {
        split (i,x,SUBSEP)
        b[x[3]]++
    }
    for (j in b) {
        print "total no:of", j, b[j]
    }
}

Alternatively, here's the one-liner:
awk '{ a[FILENAME,$1,$2] } END { for (i in a) { split (i,x,SUBSEP); b[x[3]]++ } for (j in b) print "total no:of", j, b[j] }' file{1..200}

Results:
total no:of LEU 2
total no:of ALA 4
total no:of VAL 1

