In this case, you have to pass the directory as a parameter and optionally, the single quoted file name mask as the second parameter to the shell.
On the start you do some checks:
if [ "$#" = "0" ]; then
if [ "$#" = "2" ]; then
For this, you have to pass the parameter single quoted and use find to discover your files. In the line I put "while :", you replace with
for ARQ in `find "$DIR" -type f -name "$FLIST"`
In your grep line, you must replace the "$1" parameter by "$ARQ".
Remove the shift.
Find will look for files with you specification and give it one by one for the loop. It will be recursive, so all sub-directories will be searched. If you don't give any parameter, it will look for "*.html" startin in the current directory. If you give only the directory, it will look for "*.html" starting in that directory. If you give a directory and '*.php" it will look for php files instead of html ones.