#!/bin/sh

# every directory cas/btih/{btih}/
# should contain exactly one subdirectory
# or exactly one file

zcat cas.names.txt.gz |
awk -F/ '
{
    parent = $1"/"$2"/"$3
    count[parent]++
    lines[parent] = lines[parent] $0 "\n"
}
END {
    for (p in count)
        if (count[p] > 1)
            printf "%s", lines[p]
}
'