|
我很想用一个方法能够很轻松得判别一个文件是二进制还是文本,本来很想用file命令。但实际操作发现,即便都是文本文件,所得的结果也是不同的。比如Makefile是ASCII make commands text;Bourne shell脚本是Bourne shell script text executable;C源码文件是ISO-8859 C program text, with CRLF line terminators。我知道其实用file再加上正则表达式肯定能解决,但是我觉得判断一个文件格式没必要弄那么复杂吧?所以我想问问大家有没有什么比较简单的方法来判定? |
|