Linux下文件以及文件名编码转换

1.查看文件编码方式--file 文件名(但不是很准确)
yang@mint-linux ~ $ file baidu.html 
baidu.html: HTML document, UTF-8 Unicode text, with very long lines, with no line terminators
yang@mint-linux ~ $ file sina.html 
sina.html: HTML document, ISO-8859 text, with very long lines, with CRLF, LF line terminators
2.转换文件编码--iconv -f 源编码 -t 目标编码 源文件名 > 目标文件名
yang@mint-linux ~ $ file sina.html 
sina.html: HTML document, ISO-8859 text, with very long lines, with CRLF, LF line terminators
yang@mint-linux ~ $ iconv -f gbk -t utf8 sina.html > sina_utf8.html
yang@mint-linux ~ $ file sina_utf8.html 
sina_utf8.html: HTML document, UTF-8 Unicode text, with very long lines, with CRLF, LF line terminators
3.转换文件名编码--convmv -f 源编码 -t 目标编码 文件名 --notext(如果不加--notext则只是显示结果,不实际转换)
yang@mint-linux ~ $ touch 中文.txt
yang@mint-linux ~ $ convmv -f utf-8 -t gbk 中文.txt --notest
Your Perl version has fleas #37757 #49830 
mv "./中文.txt"	"./����.txt"
Ready!

转载于:https://www.cnblogs.com/yangqionggo/p/3333898.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值