问题描述
我需要找到放置在目录中的所有文件的编码.有没有办法找到使用的编码?
I need to find the encoding of all files that are placed in a directory. Is there a way to find the encoding used?
file
命令无法执行此操作.
The file
command is not able to do this.
我感兴趣的编码是 ISO 8859-1.如果编码是别的,我想把文件移动到另一个目录.
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.
推荐答案
听起来您正在寻找 enca
.它可以猜测甚至在编码之间进行转换.只需查看手册页.
It sounds like you're looking for enca
. It can guess and even convert between encodings. Just look at the man page.
或者,如果失败,请使用 file -i
(Linux) 或 file -I
(OS X).这将输出文件的 MIME 类型信息,其中还包括字符集编码.我也找到了一个 man-page :)
Or, failing that, use file -i
(Linux) or file -I
(OS X). 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 :)
这篇关于如何通过 Linux 上的脚本找到文件的编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!