如何通过脚本查找Unix中的文件编码 [英] How to find encoding of a file in Unix via script(s)
问题描述
我需要找到放在目录中的所有文件的编码。有没有办法找到使用的编码?
文件
命令不能这样做。 p>
我感兴趣的编码是:ISO-8859-1。如果编码是其他任何东西,我想将文件移动到另一个目录。
听起来你正在寻找 ENCA
。它可以猜测甚至在编码之间转换。只需查看手册页。
否则,请使用 file -i
(linux)或 file -I
(osx)。这将输出文件的MIME类型信息,这也将包括字符集编码。我也找到了一个手册页:)
I need to find the encoding of all files that are placed in a directory. Is there a way to find the encoding used?
The file
command is not able to do this.
The encoding that is of interest to me is:ISO-8859-1. If the encoding is anything else, I want to move the file to another directory.
Sounds like you're looking for enca
. It can guess and even convert between encodings. Just look at the man page.
Or, failing that, use file -i
(linux) or file -I
(osx). That will output MIME-type information for the file, which will also include the character-set encoding. I found a man-page for it, too :)
这篇关于如何通过脚本查找Unix中的文件编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!