Use grep as below to list only filenames ( **-l** ): ( " **-maxdepth 0** " is to check on only under my_dir and it will not check sub directories in it.If you want sub-directories also to be checked , just remove that )
If your filenames having spaces in that you can use as below:
find ./* -maxdepth 0 -type f -exec grep -qi "HZ_CUST_SITE_USES_ALL" {} \; -and -exec grep -li "TERRITORY_ID" {} \;
**Edited for Solaris:**
find ./* -prune -type f -exec /usr/xpg4/bin/grep -qi "HZ_CUST_SITE_USES_ALL" {} \; -a -exec /usr/xpg4/bin/grep -li "TERRITORY_ID" {} \;
If you are sure that you do NOT have any spaces in between filenames , you can use simple for loop as below :
for file in $(find my_dir/* -maxdepth 0 -type f)
do
grep -qi "HZ_CUST_SITE_USES_ALL" "$file" && grep -il "TERRITORY_ID" "$file";
done