You can couple find with the -exec-exec argument. exampleExample:
find . -maxdepth 1 -type f -exec grep -H foo {} \;
This can be scaled, i.e. -maxdepth 2.
Edit
As mentioned in the [answer by @Stéphane Chazelas], it is advisable to restrict -type ffind option is usedto regular files so that grep does notgrep doesn't produce an error when itsthe argument is a path to a directory
-H{} grep optionactually is used to print a filename for every match (desired behavior when more than one file match)directory path:
find . -maxdepth 1 -type f -exec grep -H foo {} \;
-type fis a filter forfindthat limits the search results to files-His agrepoption used to print a filename for every match (desired behavior when more than one file match)