Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5735
  • 博文数量: 12
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2015-08-04 22:00
个人简介

酷爱大数据,数据库和数据算法技术

文章分类
文章存档

2015年(12)

我的朋友
最近访客

分类: LINUX

2015-08-04 23:49:22

#!/bin/bash

if [ -z "$1" ];
 then 
echo "Please input a directory name";
 exit 1;
 fi

if [ -z "$2" ];
 then 
echo "Please input a the file conversion";
 exit 1;
 fi

echo -n >error.log
 for i in `find $1 -name "$2"`
 do
 # echo $i 
if [ -f $i ];then
 iconv -f gb2312 -t utf8 $i -o tmp.txt 2>>error.log;
 if [ $? -eq 0 ];
 then
 echo "$i is converted successfully!"
 cp tmp.txt $i
 else
 echo -n "The file is $i , `date +'%Y-%m-%d %H:%M:%S'`">>error.log
 echo >>error.log 
fi
 #echo $i;
 fi
 done
 if [ -f tmp.txt ];then
 rm -f tmp.txt>/dev/null;
 fi

exit $?
阅读(42) | 评论(0) | 转发(0) |
0

上一篇:vi 小技巧

下一篇:如何获得外网地址

给主人留下些什么吧!~~