I have a little project to build
bash script that search in the OS ( Linux/Solaris ) the current IP address from files and replace them with other IP address.
The problem is that IP address could be in text file or in not text file as binary/data files, etc.
I use the command:
file –mime $PATH ( --mime is valid only for Linux )
In order to verify if file is text file, or not text file ( as binary or data file, etc )
Please advice if I do the correct thing. Is my conclusion correct?
For example if command:
file –mime $PATH
Return the results "text/plain"
Then its text/ascii file, if not then it's not text file ?
The second question:
--mime flag is valid only for Linux but not exists in Solaris, so what the alternative for Solaris?
As all know
file command sometimes not identify exactly the definition of the target file, so if someone have other idea how to identify text file, I will be happy to get any brilliant suggestion.