Request for shell script for listing directories, subdirs containing specific files.

I'm looking for a script which outputs the list of directories and sub directories from root level consisting of specific files. For instance I want shell script to list all the directories and subdirectories containing .txt files.:wall:

Try using find

man find         # for detail in find
find . -type f -name "*.txt"

posix,

Thanks for the providing the command. Want I really want is shell script outputing just the directories and subdirectories and not list the files.

$ find . -type f -name '*sas7b*'
./employee.sas7bdat
./employee.sas7bndx
./employee1.sas7bdat
./sasuser.v91/regstry.sas7bitm
./test/employee.sas7bdat
./test/new1.sas7bvew

I'm looking for list like following

.
./test

. is my home directory

find . -type f -name '*.txt' | nawk -F/ 'NF-- && $1=$1' OFS=/ | sort -u

No luck

$ find . -type f -name '*sas7b*' | nawk -F/ 'NF-- && $1=$1' OFS=/ | sort -u
./employee.sas7bdat
./employee.sas7bndx
./employee1.sas7bdat
./sasuser.v91/regstry.sas7bitm
./test/employee.sas7bdat
./test/new1.sas7bvew

I'm looking for list of directories and sub directories
here output I'm looking for is

.
./test
./sasuser.v91

---------- Post updated at 01:46 PM ---------- Previous update was at 12:05 PM ----------

Any other ideas?

---------- Post updated at 03:02 PM ---------- Previous update was at 01:46 PM ----------

:confused: