sed删除行尾空格,indet格式化段落
最后删除临时文件
#!/bin/bash
function read_dir()
{
for file in `ls $1`
do
subfile=$1"/"$file
if [ -d $subfile ];then
read_dir $subfile
else
if [[ $file =~ "~" ]];then
rm -rf $subfile
continue
fi
if [[ $file =~ ".config" ]];then
continue
fi
if [[ $file =~ ".c" || $file =~ ".h" ]];then
echo $subfile
indent -npro -kr -i4 -ts4 -l180 -ss -cp1 -ncs -nsob -npcs -il 0 $subfile
sed -i 's/[ \t]*$//g' $subfile
fi
fi
done
}
function clear_dir()
{
for file in `ls $1`
do
subfile=$1"/"$file
if [ -d $subfile ];then
clear_dir $subfile
else
if [[ $subfile =~ "~" ]];then
rm -rf $subfile
fi
fi
done
}
read_dir $1
clear_dir $1