注:转换操作均在Linux终端进行操作

安装工具:dos2unixunix2dos

# ubuntu
apt-get install dos2unix
apt-get install unix2dos
# centos
yum -y install ···

DOS格式转换为Unix格式

单个文件

dos2unix <filename>

多个文件(在文件夹下执行)

find -type f | xargs dos2unix -o

Unix格式转换为DOS格式

单个文件

unix2dos <filename>

多个文件(在文件夹下执行)

find -type f | xargs unix2dos -o  

gbk与UTF-8编码转换

转换gbk编码文件为utf-8编码文件

iconv -f gbk -t utf-8 in_filename.csv > out_filename.csv

转换gbk编码文件为utf-8编码文件

iconv -c --verbose  -f gbk -t utf-8 in_filename.csv -o out_filename.csv

转换utf-8编码文件为gb2312编码文件

iconv -c --verbose  -f utf-8 -t gb2312 in_filename.csv -o out_filename.csv

查看文件当前编码

file -i filename

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-07-05
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-08-03
  • 2022-01-15
  • 2021-12-14
  • 2022-01-11
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案