Chinaunix首页 | 论坛 | 博客
  • 博客访问: 838916
  • 博文数量: 1384
  • 博客积分: 27795
  • 博客等级: 上将
  • 技术积分: 16887
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-12 09:28
个人简介

只是心态,抓住机会。

文章分类

全部博文(1384)

文章存档

2014年(3)

2013年(403)

2012年(978)

分类: LINUX

2012-09-20 18:15:19

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]
阅读(1699) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~