Linux下批量修改文件編碼
更新時間:2007年01月13日 00:00:00 作者:
假設(shè)需要將所有ipaddr目錄下的php文件,編碼從gb2312轉(zhuǎn)到utf8
cd ipaddr
find ./ -type f -name "*.php"|while read line;do
echo $line
iconv -f GB2312 -t UTF-8 $line > ${line}.utf8
mv $line ${line}.gb2312
mv ${line}.utf8 $line
done
上面腳本將當(dāng)前ipaddr目錄下的所有php文件,從gb2312轉(zhuǎn)到utf8,原文保存為*.php.gb2312。
如果需要刪除原來的gb2312文件,只需執(zhí)行:
find ./ -type f -name "*.utf8" -exec rm -f {} \;
cd ipaddr
find ./ -type f -name "*.php"|while read line;do
echo $line
iconv -f GB2312 -t UTF-8 $line > ${line}.utf8
mv $line ${line}.gb2312
mv ${line}.utf8 $line
done
上面腳本將當(dāng)前ipaddr目錄下的所有php文件,從gb2312轉(zhuǎn)到utf8,原文保存為*.php.gb2312。
如果需要刪除原來的gb2312文件,只需執(zhí)行:
find ./ -type f -name "*.utf8" -exec rm -f {} \;
相關(guān)文章
在CentOS中安裝Rancher2并配置kubernetes集群的圖文教程
這篇文章主要介紹了在CentOS中安裝Rancher2并配置kubernetes集群的圖文教程,通過本文可以掌握Docker常用操作,了解K8s基本原理,本文圖文并茂給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友參考下吧2019-05-05
利用shell編程實現(xiàn)DOS風(fēng)格的Linux命令行
利用shell編程實現(xiàn)DOS風(fēng)格的Linux命令行...2006-10-10

