#!/bin/sh homeDir=$1 #cd /Users/ranwenjie/Desktop/c:c++/Bitcoin-xcode/bitcoin/src cd $homeDir # 目录内的源码统计 echo "" > /tmp/1.txt find . -maxdepth 1 -type d -print0 | while read -d '' -r dir; do files=("$dir"/*) sum=`find $files -regex '.*\.\(cpp\|c\|h\)' -type f -print0 | xargs -0 wc -l | sort -nr | head -n 1 | awk '{print $1}'` printf "%-20s %s \n" "$dir" "$sum" >> /tmp/1.txt done sort -k 2 -nr < /tmp/1.txt # src目录下的源码统计 find ./ -maxdepth 1 -regex '.*\.\(cpp\|c\|h\)' -type f -print0 | xargs -0 wc -l | sort -nr | head -n 1 | awk '{print $1}'