I believe GNU find can meet all your criteria:
$ find /top/dir -not -empty -type f -name x.txt -printf '%h\n'
The above recursively searches /top/dirfor non-empty ( -not -empty), regular ( -type f) files with a name x.txtand prints directories leading to these files ( -printf '%h\n').
source
share