dos2unix
查询脚本的格式
find . -name "*.sh" | xargs file
./disable_user_log_to_messages_for_centos.sh: Bourne-Again shell script, ASCII text executable
./distributions/centos/7/after_mdatacenter.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
./distributions/centos/7/after_xsom.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
./distributions/centos/7/influx.sh: Bourne-Again shell script, ASCII text executable
./distributions/centos/7/jdk.sh: Bourne-Again shell script, ASCII text executable
./distributions/centos/7/mongo.sh: Bourne-Again shell script, ASCII text executable
./distributions/centos/7/mssql.sh: Bourne-Again shell script, ASCII text executable
./distributions/kylin/3/after_mdatacenter.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
./distributions/kylin/3/after_xsom.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
# with CRLF line terminators 表示是dos格式,没有表示是unix
将dos格式转成unix
单个文件
dos2unix file
所有.sh文件
find . -name "*.sh" | xargs dos2unix
指定类型且是dos格式的才转换
find . -name "*.sh" | xargs file | grep CRLF | cut -d":" -f1 | xargs dos2unix
补充:编辑文件直接修改文件的格式
vim file
:set ff=unix
unix2dos
用法和dos2unix一样,是将unix格式转成dos格式