I'm currently writing a shell script that needs to be able to identify the actual type of files (not their extensions) with the unix "file" utility. However, that tool outputs human readable text which might be somewhat difficult to parse. Before I write something that just matches specific substrings found in its output, is there a better way to approach this problem?
|
feedback
|
|
Using the
The
| |||
|
feedback
|

fileshould suffice e.g. one way to parse out the character set:raw=$(file -i $1); cset=${raw#*=}. – hesse Jan 7 at 20:24