mac 批量文件编码格式转换

来源:互联网 发布:凸的网络意思是什么 编辑:程序博客网 时间:2024/05/24 03:03

mac 批量文件编码格式转换

#!/bin/shfor file in `find ./ -name "*.c"`;doecho convering : $fileiconv -f GBK -t utf-8 $file > $file.tmv $file.t $filedoneecho 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.tmv $3.t $3

带参数批量转换指定目录及子目录文件格式
批量转指定目录下的 .h, .c等文件编码格式

#!/bin/shecho "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 $filedoneecho DONE

查看文件

head file
原创粉丝点击