I'm writing a script that will search files that contain certain keywords, and then output the line to a text file.
The problem I'm having is that the script is opening every type of file, including executables.
The script seems to work fine, as in it doesn't crash when it opens these types of files, but the problem I'm having is with the output.
When the script outputs text from some type of non-text-based file, I cannot open the file with gedit. It gives me the "gedit has not been able to detect the character encoding." error.
So here is my question.
Either A) I need to have the script only open and search text-based files or B), I need to force the script to output using a specific encoding so that I can open and read the output file.
I tried having the script using the file extension, but there are way too many extensions to try to list, so I was hoping for a more elegant solution.
One more piece of information, this script will be used to search files on both Windows and *NIX boxes (but mainly Windows). However, the script itself will be run on Linux.
Thanks.
Jason