hi, does any one know how to compare a file1 with many files and have to count a number (i.e. 1) like the following ..Thanx in advance
input
file1 file2 file3 filen
1 1 1 1
1 1 1 1
1 1 1 1
0 1 1 1
1 0 0 0
1 0 0 0
0 0 0 0
1 0 1 0
output
instances in file1 only - 2
instances in all files but not file1-1
instances in all files - 3
instances in none - 1
I am doing some thing like this
awk '{print $1"_"$2"_"$3"_"$4}' $1 | awk '{h[$1]++}; END { for(k in h) print k, h[k] }' |grep -v file
Subbeh
4
One way to do it:
instances in file1 only:
paste file1 file2 file3 file4 | grep -c '^1[^1]*$'
instances in all files but not file1:
paste file1 file2 file3 file4 | grep -c '^0[^0]*$'
instances in all files:
paste file1 file2 file3 file4 | grep -c '^[^0]*$'
instances in none:
paste file1 file2 file3 file4 | grep -c '^[^1]*$'