海之石

导航

 
#! /bin/bash
   
  filesCount=0
  linesCount=0
  function funCount()
  {
          for file in `ls $1`
          do
                  if [[ "$file" == "conf" ]];then
                          if [ -d $file ]; then
                                  continue
                          fi
                  elif [ -d $1"/"$file ];then
                          funCount $1"/"$file
                  elif [[ "$file" == *.o ]];then
                          continue
                  elif [[ "$file" == *.a ]];then
                          continue
                  elif [[ "$file" == *.so ]];then
                          continue
                  elif [ -L $1"/"$file ];then
                          continue
                  #elif [[ "$file" == "conf" ]];then
                  #       continue
                  else
                          declare -i fileLines
                          fileLines=`awk 'BEGIN{count=0} { count++ } END{print count}' $1"/"$file `
                          let linesCount=$linesCount+$fileLines
                          let filesCount=$filesCount+1
                  fi
          done
  }
  
  
  if [ $# -gt 0 ];then
          for m_dir in $@
          do
                  funCount $m_dir
          done
  else
funCount "." fi

  排除了库文件,配置文件,软连接的情况

posted on 2017-10-27 17:50  海之石  阅读(168)  评论(0编辑  收藏  举报