1. 查询当前目录下所有没有后缀名的文件:
find . -type f -and ! -name "*.*"
2. 查询当前文件夹下所有用Windows换行符(CRLF)并且没有后缀名的文件,使用-m参数后则转换成unix format (LF).
#!/bin/bash
TERM=linux
export TERM
#for i in $(find . -type f -and ! -name "*.*" ); do
# if file $i | grep CRLF ; then
# echo $i
# file $i
# #dos2unix "$i"
# fi
#done
for i in $(find . -type f -and ! -name "*.*" ); do
if head -n 20 $i | grep -qs $'\r' ; then
echo $i
if [[ $1 = "-m" ]]
then
dos2unix "$i"
fi
fi
done
资料:
http://stackoverflow.com/questions/5346523/how-to-find-a-windows-end-of-line-eol-character