Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79755
  • 博文数量: 44
  • 博客积分: 286
  • 博客等级: 二等列兵
  • 技术积分: 335
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-23 11:02
文章分类
文章存档

2013年(2)

2012年(42)

我的朋友

分类:

2012-09-25 23:57:05

原文地址:dos2unix批量转换的脚本 作者:n73man001

dos2unix批量转换的脚本 (2007-05-25 15:45:15)
dos2unix批量转换的脚本

  在windows平台上使用source insight开发时,常常会有文件格式的问题,我们知道dos2unix可以完成从dos格式到unix格式的转换,但是最好能够有一个现成的批量转换脚本。

#!/bin/sh
foreachd () {
  echo $1
  for file in $1/*
  do
    if [ -d $file ]
    then
      echo "directory $file"
      foreachd $file
    fi

    if [ -f $file ]
    then
      echo "file $file"
      dos2unix $file
      chmod -x $file
    fi

  done
}

echo $0
a=`echo $1`
if [ $# -gt 0 ]
then
  foreachd $a
else
  foreachd "."
fi

使用方法:
dos2unix.sh [path]
阅读(400) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~