Linux下批量修改文件編碼
更新時(shí)間: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。
如果需要?jiǎng)h除原來(lái)的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。
如果需要?jiǎng)h除原來(lái)的gb2312文件,只需執(zhí)行:
find ./ -type f -name "*.utf8" -exec rm -f {} \;
相關(guān)文章
CentOS6.5 上部署 MySQL5.7.17 二進(jìn)制安裝以及多實(shí)例配置
這篇文章主要介紹了CentOS6.5 上部署 MySQL5.7.17 二進(jìn)制安裝以及多實(shí)例配置,需要的朋友可以參考下2017-01-01詳解shell中source、sh、bash、./執(zhí)行腳本的區(qū)別
這篇文章主要介紹了shell中source、sh、bash、./執(zhí)行腳本的區(qū)別,需要的朋友可以參考下2017-11-11Linux系統(tǒng)中xorg.conf文件詳細(xì)介紹
以下是對(duì)Linux系統(tǒng)中的xorg.conf文件進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下2013-08-08深入數(shù)據(jù)驅(qū)動(dòng)編程之表驅(qū)動(dòng)法的詳解
本篇文章是對(duì)表驅(qū)動(dòng)法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05