Since you say you have a nested folder structure, I believe *data*/*txt
won’t do what you need. I suggest
find . –type d –name "*data*" –exec sh –c "grep sampletext /dev/null {}/*.txt" \;
The /dev/null
is there to force grep
to display the filename even when it runs on a directory that has only one .txt
file in it.