I have a little project to build a bash script that searches the OS (Linux/Solaris) for the current IP address in files, and replaces them with another IP address.
The problem is that IP address could be in text files or in non-text files such as binary/data files.
I use the command:
file --mime $PATH (--mime is valid only for linux)
In order to verify if a file is a text file, or not a text file (as binary or data file etc.)
Is that correct?
For example if I have the command:
file --mime $PATH (returns the results "text/plain")
Then it's a text/ASCII file, if not then it's not a text file?
The second question:
file --mime "--mime"
The flag is valid only for Linux but not in Solaris, so what is the alternative for Solaris?
The file command sometimes does not identify exactly the definition of the target file, so if someone has other ideas on how to identify the text file…?