Grep through subdirectories

Use the -R (equivalent to --recursive) option to grep.

EDIT: after reading the thread, in the combination ls /mydata | grep txt$ you do not need recursive grep, but recursive ls. You do not grep the files; you grep the output of ls, which happens to be a list of files.

"Recursive ls" is called find :-)

find /mydata -type f | grep txt$

or, better,

find /mydata -type f -name '*.txt'

I actually solved it by using find . type -f instead of ls