linux 文件批量转utf8

本文详细介绍了如何从官方网站下载并安装enca字符集检测工具,提供了完整的安装命令流程,包括验证安装是否成功及版本的方法。此外,还示范了如何利用enca批量转换文件,以将当前目录下及其子目录中的Python文件统一转换为UTF-8编码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载安装 enca  官网:https://dl.cihar.com/enca/

wget https://dl.cihar.com/enca/enca-1.19.tar.xz && \
tar -Jxvf enca-1.19.tar.xz && \
cd enca-1.19 && \
./configure --prefix=/usr/local/enca-1.19 && \
make && make install && \
export PATH=/usr/local/enca-1.19/bin:$PATH 

验证安装是否成功及版本:

[root@localhost enca-1.19]$enca --version
enca 1.19

Features: -librecode-interface +iconv-interface +external-converter +language-detection +locale-alias +target-charset-auto +ENCAOPT

Copyright (C) 2000-2005 David Necas (Yeti) (<yeti@physics.muni.cz>),
              2005 Zuxy Meng (<zuxy.meng@gmail.com>).

Enca is free software; it can be copied and/or modified under the terms of
version 2 of GNU General Public License, run `enca --license' to see the full
license text.  There is NO WARRANTY; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

 

2.批量转换文件

实例:把当前目录下 及其 子目录中的 python文件转为utf8

find . -type f -name "*.py" -exec enca -L zh_CN -x UTF-8 {} \;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值