实现dos2linux功能-shell脚本篇
2012-11-12 19:58
591 查看
#! /bin/bash # Programe: # To change the the file with end of \r\n, into linux style with end of \n # History: # 2012/11/12 ZL FirstRelease # function: # To ergodic the diretory function ergodic(){ for file in ` ls $1 ` do if [ -d $1"/"$file ] then ergodic $1"/"$file else file="$1"/"$file" func $file; echo "$file"; read -p "dd" X fi done } # Function: # To make the file with end of \r\n into \n function func () { tmp=".tmp"; echo > .tmp sed 's/\r$//g' $1 >> .tmp # \r\n ===> \n cat $tmp > $1 sed -i '1d' $1 } # Function: # To start the main read -p "Please input the file/directory(U want change the dos style to unixone):" INIT_PATH; INIT_PATH=`echo $INIT_PATH | sed 's/\/$//g'`; #"/home/" ===> "/home" ergodic $INIT_PATH
相关文章推荐
- shell脚本实现文件锁功能
- Shell脚本中调用expect,实现自动输入密码的功能
- 利用shell脚本实现计划任务功能
- 通过linux的crontab实现定时执行shell脚本功能
- shell脚本之微信报警功能的实现
- shell脚本结合函数实现简单计算器功能
- 【原创】一个shell脚本记录(实现rsync生产文件批量迁移功能)
- 利用shell脚本实现计划任务功能 V1.2(持续更新)
- 利用shell脚本实现计划任务功能 V1.2
- 使用shell脚本实现自动SSH互信功能
- shell脚本实现进度条功能
- 利用shell脚本实现计划任务功能
- shell脚本实现文件锁功能
- shell脚本实现查找文件夹下重复的文件,并提供删除功能
- 利用shell脚本实现计划任务功能
- 详解shell脚本(十二)—— 进阶功能实现
- Ruby和Shell脚本实现判断成绩及格功能
- shell脚本实现ssh自动登录-功能扩展,实现多个IP可选
- shell实现一个简单的计算器功能小脚本
- Shell脚本中实现字符串变量的去重功能