Linux(Centos 7.6)命令详解:iconv

1.命令作用

将给定文件的编码从一种编码转换为另一种编码(Convert encoding of given files from one encoding to another)

2.命令语法

Usage: iconv [OPTION...] [FILE...]

3.参数详解

OPTION:
输入/输出格式规范:

  • -f, --from-code=NAME,原始文本编码
  • -t, --to-code=NAME,输出文件编码(目标文件编码)

信息:

  • -l, --list,列出所有已知的编码字符集

输出控制:

  • -c,从输出中省略无效字符(静默丢弃无法转换的字符,而不是在遇到此类字符时终止)
  • -o, --output=FILE,输出文件
  • -s, --silent,抑制警告
  • --verbose,打印进度信息

4.常用用例

## 将文件log1从UTF8格式转换为GBK格式,并输出到log1.1
[root@localhost test]# file log.csv
log.csv: UTF-8 Unicode text
[root@localhost test]# 
[root@localhost test]# iconv -f UTF-8 -t GBK log.csv -o log1.csv
[root@localhost test]# 
[root@localhost test]# file log1.csv
log1.csv: ISO-8859 text
[root@localhost test]# 

你可能感兴趣的:(linux,centos,运维)