 
TA的每日心情 | 奋斗 2019-10-18 11:20 |
---|
签到天数: 678 天 [LV.9]以坛为家II
|
当linux下有多个dos格式的文件要转换成unix的时候,下面这个脚本很适合大家使用的,一个一个的去改真要让人崩溃.
脚本内容:
vi dos2unix- #!/bin/bash
- showUsage()
- {
- echo "Usage: dos2unixdir [destdir]"
- exit 0
- }
- dir=$PWD
- if [ $# -gt 1 ]
- then
- showUsage
- fi
- if [ $# -gt 0 ]
- then
- dir=$1
- fi
- for i in `find $dir`
- do
- if [ ! -d $i ]
- then
- echo "processing file..." $i
- dos2unix $i $i
- fi
- done
复制代码 使用方法:
dos2unix a.txt b.txt
要把一批文件都dos2unix,可以用下面的for语句:
for f in *.txt 或for f in *
do
dos2unix $f
done
|
|