1、查看当前目录下所有文件编码:
查当前目录的所有文件用 '*' 就可以
查单个文件指定单个文件即可
[root@cs174 export]# find . -name 'test.csv' | xargs file
./test.csv: UTF-8 Unicode text
[root@cs174 export]# find . -name '*' | xargs file
.: directory
./export16f234cc1c55056d0000000000000001-n764712270076542977.0.csv: UTF-8 Unicode text
./test.csv: UTF-8 Unicode text
./item-gb.csv: Non-ISO extended-ASCII text, with LF, NEL line terminators
[root@cs174 export]#
2、更换文件的编码:
iconv工具,也可以在软件源安装 yum install iconv
iconv -f 源编码 -t 目标编码 原文件名 -o 输出文件名
# 例如:将utf8.txt从UTF-8编码改为gb18030编码
iconv -f UTF-8 -t gb18030 utf8.txt -o gb18030.txt