小编med*_*iev的帖子

如何让 iconv 用转换后的输出替换输入文件?

我有一个 bash 脚本,它枚举目录中的每个 *.php 文件并应用于iconv它。这将在 STDOUT 中获得输出。

由于添加-o参数(根据我的经验)实际上可能在转换发生之前写入一个空白文件,我如何调整我的脚本以进行转换,然后覆盖输入文件?

for file in *.php
do
    iconv -f cp1251 -t utf8 "$file"
done
Run Code Online (Sandbox Code Playgroud)

shell io-redirection text-processing

79
推荐指数
2
解决办法
6万
查看次数

标签 统计

io-redirection ×1

shell ×1

text-processing ×1