在將windows上的jsp網頁移植到linux環境中時,發現一個個的轉換編碼及修改默認編碼類型太慢,寫此腳本進行嘗試文件遍歷。
#!/bin/bash
SPATH="/root/cheng"
DIR=WebRoot
DPATH="/web"
find ${DIR} -type d -exec mkdir -pv ${DPATH}/{} \;
find ${DIR} -type f -exec iconv -f GBK -t UTF-8 {} -o ${DPATH/{} \;
echo "The file Next Listed is not a common file or directory ,please check."
find ${DIR} ! -type f -a ! -type d -ecec ls -l {} \;
find $DPATH -type f -exec sed -i -e 's/gb2312/UTF-8/g' -e 's/GB2312/UTF-8/g' {} \;
echo ' '
echo "All Done."