mac 批量文件编码格式转换
#!/bin/sh
for file in `find ./ -name "*.c"`;
do
echo convering : $file
iconv -f GBK -t utf-8 $file > $file.t
mv $file.t $file
done
echo DONE
查看文件编码格式
#!/bin/sh
if [ ! $# == 2 ]; then
echo "Usage: filecode utf8 1.c"
echo "Usage: filecode gbk 1.c"
exit
fi
iconv -f $1 $2 1>/dev/null 2>/dev/null && echo 'ok'
文件格式转换
#!/bin/sh
if [ ! $# == 3 ]; then
echo "Usage: conv utf8 gbk 1.c"
exit
fi
iconv -f $1 -t $2 $3 > $3.t
mv $3.t $3
带参数批量转换指定目录及子目录文件格式
批量转指定目录下的 .h, .c等文件编码格式
#!/bin/sh
echo "h.sh directory c"
echo "h.sh directory h"
for file in `find $1 -name "*.$2"`;
do
echo convering : $file
iconv -f GBK -t utf-8 $file > $file.t
mv $file.t $file
done
echo DONE
查看文件
head file