If I grep in a folder that has files and directories, I get warning and error messages like
grep: img: Is a directory
In case you’d like to skip the warnings and errors, use the option -s that will do the job for you.
grep -s "<?" *
Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, 7th Edition Unix grep did not conform to POSIX, because it lacked -q and its -s option behaved like GNU grep’s -q option. USG-style grep also lacked -q but its -s option behaved like GNU grep. Portable shell scripts should avoid both -q and -s and should redirect standard and error output to /dev/null instead. (-s is specified by POSIX.)