shell应用:批量将文件编码由gbk转utf-8

一键批量转换:如何高效将文件编码统一为UTF-8 本文详细介绍了如何高效地将文件编码批量统一为UTF-8,以解决跨平台、跨系统协作中的乱码问题。文章对比了手动转换的痛点,并提供了三种高效的批量转换方案:使用VS Code编辑器进行图形化操作、利用Linux/macOS内置的iconv与find命令行工具组合,以及编写灵活的Python脚本实现智能编码检测与转换。每种方法都包含详细步骤和注意事项,帮助开发者与内容管理者一劳永逸地解决编码混乱难题。 阅读详情


实例代码:

#!/bin/bash

// batch_change_GB2312_to_UTF-8

cd directory
find ./ -type f -name "*.java" | while read line;do
echo $line
iconv -f GB2312 -t UTF-8 $line > ${line}.utf8
mv $line ${line}.gb2312
mv ${line}.utf8 $line
done


Shell GBK文件转UTF-8文件处理脚本 Shell脚本,实现gbk文件到utf-8文件之间的转换。用于开发测试时将Windows上传的文件转换成所需的格式。 立即下载

相关推荐

Shell脚本把文件从GBK转为UTF-8编码

主要介绍了Shell脚本把文件从GBK转为UTF-8编码,需要的朋友可以参考下

shell中encoding=utf-8_如何在Linux中将文件编码转换为UTF-8-阿里云开发者社区

在这篇教程中,我们将解释字符编码的含义,然后给出一些使用命令行工具将使用某种字符编码的文件转化为另一种编码的例子。最后,我们将一起看一看如何在 Linux 下将使用各种字符编码的文件转化为 UTF-8 编码。你可能已经知道,计算机除了二进制数据,是不会理解和存储字符、数字或者任何人类能够理解的东西的。一个二进制位只有两种可能的值,也就是 0 或 1,真或假,是或否。其它的任何事物,比如字符、数据和...

weixin_39522312的博客 1092

火星遥感数据的获取与处理工具安装详解

有关火星遥感影像数据的那些事...

FengYingLuo的博客 5572

linxu shell iconv 转码问题

一、查看文件编码。 在打开文件的时候输入:set fileencoding 即可显示文件编码格式。二、文件编码转换 1、在Vim中直接进行转换文件编码,比如将一个文件转换成utf-8格式 在打开的文件中输入:set fileencoding=utf-8 2、使用iconv转换,iconv的命令格式如下: ico...

weixin_33961829的博客 1319

机器人强化学习入门学习笔记

如果你追求高精度动力学仿真、用于强化学习或机器人研究,MuJoCo 是一个非常优秀的选择。如果需要快速实验、使用真实机器人模型,PyBullet 或 Gazebo可能更合适;如果你追求大规模并行训练,Isaac Gym 或 BraX会更高效。legged gym底层是​编辑isaacgym,基于gpu训练可以多环境并行训练,收敛到一个稳定行走的策略快。本视频MuJoCo基于cpu训练很慢。

xiaomu_347的博客 1453

Android13 AudioFlinger混音流程全解析:从prepareTracks_l到threadLoop_write的底层实现

本文深入解析Android13 AudioFlinger混音流程,从prepareTracks_l到threadLoop_write的底层实现。详细剖析MixerThread的核心工作循环,包括音轨预处理、混音算法执行及硬件写入机制,帮助开发者优化音频性能并处理多音轨场景。

tea88的博客 1130

Shell遍历文件夹文件,以GBK转UTF-8为例

#!/bin/bash echo "bakuping ..." cp $1 $1-bakup -r echo "converting..." downdir() { for file in `ls $1` do if [ -d $1/$file ] then downdir $1"/"$file else #echo -e $1/$file file $1/$file|grep -i "$1/$file: ISO-8859 text" && echo "Conve

An introvert extrovert 的博客 808

FPGA学习之路—应用程序—原码二位乘法器及Verilog代码分析

FPGA学习之路——原码二位乘法器及Verilog代码分析 原理 原码乘法可以分为原码一位乘和原码二位乘,两者在实现规则上大同小异。原码一位乘每次判断乘数的最低位,对被乘数和部分积进行相应操作。而原码二位乘则是对乘数的低二位进行判断,并执行相关操作。 两位乘数的取值可以有四种可能组合,每种组合对应于以下操作: 00相当于0x,部分积Dresult右移2位,不进行其他运算; 01相当于1x,部分积D...

谦豫 3716

shell脚本实现编码格式转换

本文介绍使用linux shell脚本实现编码格式转换,实现GBK和UTF-8格式的文件互相转换。

qq_34274094的博客 1801

“三进制”bonsai27b+NInfer=6g显存闪电侠(token真的自由了!)

本文将1.58-bit三元大模型Bonsai27B成功移植至NInfer推理引擎,并在RTX 4080 SUPER上实现100+ token/s的极速推理。通过自研补丁扩展NInfer支持Ada架构与三元量化格式,解决激活布局、行置换等关键bug,实测PPL 6.445,单流吞吐达96.7–130.8 t/s,20题基准得分16/20。附完整复现包(含文档、工具、源码补丁),零权重分发,助力垃圾显卡跑通27B级模型。

shensanshu的博客 1万+

MATLAB自动驾驶(1)——预构建场景库

MATLAB自动驾驶(1)——预构建场景库

Ucicorn Gundam的博客 3265

Shell应用:批量将文件编码由gbk转utf-8

Shell应用:批量将文件编码由gbk转utf-8,实例代码: [plain] #!/bin/bash //batch_change_GB2312_to_UTF-8 cddirectory find./-typef-name"*.java"|whilereadline;do echo$line icon...

weixin_30408309的博客 150

FLUENT Meshing Watertight Geometry工作流入门 - 5 生成表面网格

我们学习在生成表面网格任务下的不同输入。讨论了局部尺寸控制与全局尺寸控制的影响。最后,讨论了如何改进表面网格,以实现好的体网格质量。

B_etter_Man的博客 5633

shell脚本-批量gbk转utf-8

这里写自定义目录标题背景代码碰到的问题 背景 原因很简单,当初工程拆分,把老代码的gbk文件原封不动的挪到了新的工程,gradle编译已经指定了options.encoding = “UTF-8” 但是还是会出现gbk乱码导致编译不成功。只怪自己太菜不会用gradle解决,只能退而求其次用shell脚本进行gbk转utf-8. 代码 在#!/bin/sh isEnc() { local temp=`iconv -f $2 $1 1>/dev/null 2>/dev/null &amp

学习小窝 2523

华为OD新系统机试真题 - 获取大写字母瓷砖拼出独特图案数量

华为OD机试新系统真题【获取大写字母瓷砖拼出独特图案数量】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD新系统四月二十九号机试真题【获取大写字母瓷砖拼出独特图案数量】

qq_45776114的博客 1218

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

简单shell批量文件转换gbk转为utf8编码

shell实现gbk批量转换utf8

flysnownet的博客 2404

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

shell中encoding=utf-8_linux shell 中文件编码查看及转换方法

一、查看文件编码。在打开文件的时候输入:set fileencoding即可显示文件编码格式。二、文件编码转换1、在Vim中直接进行转换文件编码,比如将一个文件转换成utf-8格式在打开的文件中输入:set fileencoding=utf-82、使用iconv转换,iconv的命令格式如下:iconv -f encoding -t encoding inputfile比如将一个 编码的文件转换成...

weixin_39621060的博客 4464

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

linux shell 批量更改文件编码格式 gbk到utf-8

for i in `find ./  -type f -name '*.TXT'` ; do         echo $i         echo ${i}.tmp         iconv -f gbk -t utf-8  $i>${i}.tmp         mv ${i}.tmp $i; done

carmazhao的专栏 6356

Linux 文本文件编码GBK转UTF-8

Linux服务器中调用Oracle卸数工具sqluldr2,数据库编码为GBK,需要卸UTF-8的数据文件出来,如果某个字段为中文,因为GBK为两个字节,UTF-8为三个字节,同样是10个汉字,直接卸UTF-8编码的长度是原来GBK的1.5倍,如果已经超过这个字段的长度,卸数时会直接截取,导致字段后面字符串丢失。遇到这种问题,可以考虑先正常卸GBK的数据文件出来,再用iconv将GBK文件转码成UTF-8。 iconv -c -f GBK -t UTF-8 gbkfilename.txt -o utf8

Denglishang的博客 4327

Linux下GBK文件编码批量转换UTF-8命令

使用iconv 转换 Iconv语法:iconv -f encoding -t encoding inputfile 单个文件转换: $ iconv -f GBK -t UTF-8 file1 -o file2 批量转换: $ find default -type d -exec mkdir -p utf/{} \; $ find default -type f -exec iconv...

xld123 3679

UTF、GBK等编码以及嵌入式linux支持中文显示

1 各种字符编码 1.1 ASCII      Ascii:ASCII(American Standard Code for Information Interchange,美国标准信息交换代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言,采用单字节编码,即一个字符只占用一字节。我们所长用的只有0-127共128个字符,128~255是扩展字...

weixin_43369409的博客 4414

批量文件转码工具(支持GBK,UTF-8转换)

批量文件转码工具(支持GBK,UTF-8转换) 使用依赖环境:Linux操作系统 shell iconv 功能:通过命令行指定要转码文件所在的目录,本程序将把该目录及其子目录下的所有文件从GBK编码转换为UTF-8编码 注意:如果指定的目录下有非文本文件或文本文件编码不是GBK,请先备份这些文件,以免给你带来损失。 使用例子: 1、拷贝该文件并保存为gbk2utf8.sh 并赋予可执行权限 2、在shell下执行如下命令: ./gbk2utf8.sh files files是待转码文件所在..

u013910871的博客 2914

Linux 下使用 iconv 批量 GBK 文件编码转换为 UTF-8 文件

Linux 下使用 iconv 批量 GBK 文件编码转换为 UTF-8 文件 install -Dm755 /dev/stdin gbk2utf-8.sh <<EOF #!/bin/sh for i in * do iconv -f GBK -t UTF-8 $i >cache_file cp cache_file $i done rm cache_file EOF

饕餮人的博客 1257
上一篇: httpclient介绍
下一篇: shell应用:批量添加用户
「已注销」
博客等级 码龄20年 47粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值